File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 1- name : Build and Push Docker Image
1+ name : Build, Scan and Push Docker Image
22
33on :
44 push :
88 build :
99 runs-on : ubuntu-latest
1010
11+ outputs :
12+ image-tag : ${{ steps.tag.outputs.sha_tag }}
13+
1114 steps :
1215 - name : Checkout code
1316 uses : actions/checkout@v3
1417
18+ - name : Set image tag
19+ id : tag
20+ run : echo "sha_tag=${GITHUB_SHA}" >> $GITHUB_OUTPUT
21+
1522 - name : Log in to DockerHub
1623 uses : docker/login-action@v2
1724 with :
2835 IMAGE_BASE=${{ secrets.DOCKERHUB_USERNAME }}/myhello
2936 docker push $IMAGE_BASE:latest
3037 docker push $IMAGE_BASE:${{ github.sha }}
38+
39+ scan :
40+ runs-on : ubuntu-latest
41+ needs : build
42+
43+ steps :
44+ - name : Checkout code
45+ uses : actions/checkout@v3
46+
47+ - name : Trivy Image Scan
48+ uses : aquasecurity/trivy-action@master
49+ with :
50+ image-ref : ${{ secrets.DOCKERHUB_USERNAME }}/myhello:${{ needs.build.outputs.image-tag }}
51+ format : ' table'
52+ exit-code : ' 1'
53+ ignore-unfixed : true
54+ vuln-type : ' os,library'
55+ severity : ' CRITICAL,HIGH'
56+
57+ - name : Trivy FS Scan (source & Dockerfile)
58+ uses : aquasecurity/trivy-action@master
59+ with :
60+ scan-type : ' fs'
61+ scan-ref : ' .'
62+ format : ' table'
63+ exit-code : ' 1'
64+ ignore-unfixed : true
65+ vuln-type : ' os,library'
66+ severity : ' CRITICAL,HIGH'
You can’t perform that action at this time.
0 commit comments