1+ name : Publish Python 🐍 distribution 📦 to PyPI
2+
3+ on :
4+ push :
5+ tags :
6+ - ' test'
7+ branches :
8+ - docker-build
9+
10+ jobs :
11+ docker-build :
12+ name : Build and Push Docker Image
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Set up QEMU
20+ uses : docker/setup-qemu-action@v3
21+
22+ - name : Set up Docker Buildx
23+ uses : docker/setup-buildx-action@v3
24+
25+ - name : Extract tag version
26+ id : extract_tag
27+ run : echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
28+
29+ - name : Build docker image
30+ uses : docker/build-push-action@v6
31+ env :
32+ DOCKER_BUILD_SUMMARY : false
33+ with :
34+ # Caching options
35+ cache-from : type=gha
36+ cache-to : type=gha,mode=max
37+ # The actual build arguments
38+ context : .
39+ file : ./Dockerfile
40+ tags : |
41+ veridise/audithub-client:${{ env.IMAGE_TAG }}
42+ push : false
43+ load : true
44+
45+ - name : Run Trivy vulnerability scanner on the image
46+ env :
47+ # if primary fails, this will use ghcr.io as the primary and public.ecr.aws then.
48+ TRIVY_DB_REPOSITORY : ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
49+ uses : aquasecurity/trivy-action@0.32.0
50+ with :
51+ image-ref : " veridise/audithub-client:${{ env.IMAGE_TAG }}"
52+ format : " table"
53+ exit-code : " 1"
54+ ignore-unfixed : true
55+ vuln-type : " os,library"
56+ severity : " CRITICAL,HIGH"
57+ output : " trivy-scan.txt"
58+
59+ - name : Publish Trivy Output to Summary
60+ if : failure() # run this step if previous step failed
61+ run : |
62+ if [[ -s trivy-scan.txt ]]; then
63+ {
64+ echo "### Security Output"
65+ echo "<details><summary>Click to expand</summary>"
66+ echo ""
67+ echo '```terraform'
68+ cat trivy-scan.txt
69+ echo '```'
70+ echo "</details>"
71+ } >> $GITHUB_STEP_SUMMARY
72+ fi
73+
74+ - name : Login to DockerHub
75+ uses : docker/login-action@v3
76+ with :
77+ username : ${{ secrets.DOCKERHUB_USERNAME }}
78+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
79+
80+ - name : Build and push image
81+ if : success()
82+ uses : docker/build-push-action@v6
83+ with :
84+ context : .
85+ file : ./Dockerfile
86+ push : false
87+ tags : veridise/audithub-client:${{ github.sha }}, veridise/audithub-client:${{ env.IMAGE_TAG }}
88+ # Caching options
89+ cache-from : type=gha
90+ cache-to : type=gha,mode=max
0 commit comments