test build and scan #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Push, and Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- uses: actions/checkout@v2 | |
- name: Set env | |
run: echo "GITHUB_BRANCH=$(echo $GITHUB_REF_NAME-$GITHUB_SHA)" >> $GITHUB_ENV | |
- name: Build Docker image | |
run: | | |
docker buildx create --use | |
docker buildx inspect default --bootstrap | |
docker buildx build --file Dockerfile -t mhaidir32/node-js-sample-akash:$GITHUB_REF_NAME-$GITHUB_SHA --load . | |
container_scanning: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: build local container | |
uses: docker/build-push-action@v2 | |
with: | |
tags: mhaidir32/node-js-sample-akash:${{ github.sha }} | |
push: false | |
load: true | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: 'mhaidir32/node-js-sample-akash:${{ github.sha }}' | |
format: 'json' | |
exit-code: '1' | |
ignore-unfixed: true | |
vuln-type: 'os,library' | |
severity: 'MEDIUM' | |
continue-on-error: true # allow the build to fail, similar to "allow_failure: true" in GitLab |