11---
2- name : Build and Push Docker Image
2+ name : 🛠️ Build and Push Docker Image
33on :
44 push :
55 branches : [main]
66 workflow_dispatch :
77permissions :
88 contents : read
99 packages : write
10+ id-token : write # ✅ Required for provenance signing
1011jobs :
11- build-and-push-docker-image :
12+ build-and-push :
1213 runs-on : ubuntu-latest
1314 steps :
14- - name : Checkout repository
15+ - name : 📥 Checkout Repository
1516 uses : actions/checkout@v4
16- - name : Set up Docker Buildx
17+ - name : 🔧 Set up Docker Buildx
1718 uses : docker/setup-buildx-action@v3
18- - name : Log in to GitHub Container Registry
19+ - name : 🔐 Log in to GitHub Container Registry
1920 run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }}
2021 --password-stdin
21- - name : Set up Python and install Commitizen
22+ - name : 🐍 Set up Python & Install Commitizen
2223 uses : actions/setup-python@v5
2324 with :
2425 python-version : ' 3.13'
25- - name : Install Commitizen
26+ - name : 📦 Install Commitizen
2627 run : pip install commitizen
27- - name : Extract version from Commitizen
28+ - name : 🔍 Extract Version from Commitizen
2829 id : get_version
2930 run : |
3031 VERSION=$(cz version --project)
@@ -33,11 +34,32 @@ jobs:
3334 exit 1
3435 fi
3536 echo "VERSION=$VERSION" >> $GITHUB_ENV
36- - name : Build and push Docker image
37- run : |-
37+ echo "🆕 Version = $VERSION"
38+ - name : 🏗️ Build and Push Docker Image
39+ run : |
3840 docker buildx build \
3941 --push \
4042 --tag ghcr.io/${{ github.repository }}:latest \
4143 --tag ghcr.io/${{ github.repository }}:${{ github.sha }} \
4244 --tag ghcr.io/${{ github.repository }}:${{ env.VERSION }} \
4345 .
46+ - name : 📜 Generate SBOM for Docker Image
47+ run : |
48+ pip install syft==0.98.0
49+ syft ghcr.io/${{ github.repository }}:${{ env.VERSION }} -o cyclonedx-json > sbom.image.json
50+ - name : 🧾 Get Image Digest
51+ run : |
52+ IMAGE_DIGEST=$(syft ghcr.io/${{ github.repository }}:${{ env.VERSION }} -o json | jq -r '.artifacts[0].digest')
53+ echo "IMAGE_DIGEST=$IMAGE_DIGEST" >> $GITHUB_ENV
54+ - name : 📤 Upload SBOM
55+ uses : actions/upload-artifact@v4
56+ with :
57+ name : sbom-image
58+ path : sbom.image.json
59+ retention-days : 30
60+ - name : 📝 Summary Report
61+ run : |-
62+ echo "### 🐳 Docker Image Build Summary" >> $GITHUB_STEP_SUMMARY
63+ echo "- Version: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
64+ echo "- Image Digest: ${{ env.IMAGE_DIGEST }}" >> $GITHUB_STEP_SUMMARY
65+ echo "- SBOM file: sbom.image.json" >> $GITHUB_STEP_SUMMARY
0 commit comments