Skip to content

Commit 9cfa962

Browse files
committed
chore: update workflows to add new sbom features
Verified workflows work with the sbom analysis Added vulnerability report on pre-commit
1 parent 2a5a85b commit 9cfa962

File tree

8 files changed

+62
-17
lines changed

8 files changed

+62
-17
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: 🔐 Attest Build Provenance
3+
on:
4+
push:
5+
tags: [v*.*.*]
6+
permissions:
7+
id-token: write
8+
contents: read
9+
jobs:
10+
provenance:
11+
name: Generate SLSA Provenance
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: 📥 Checkout Source Code
15+
uses: actions/checkout@v4
16+
- name: 🧾 Generate Provenance Attestation
17+
uses: slsa-framework/slsa-github-generator/actions/provenance@v1
18+
with:
19+
builder-id: https://github.com/${{ github.repository }}/.github/workflows/Build%20and%20Push%20Docker%20Image.yml@refs/tags/${{
20+
github.ref_name }}
Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
---
2-
name: Build and Push Docker Image
2+
name: 🛠️ Build and Push Docker Image
33
on:
44
push:
55
branches: [main]
66
workflow_dispatch:
77
permissions:
88
contents: read
99
packages: write
10+
id-token: write # ✅ Required for provenance signing
1011
jobs:
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

.github/workflows/GitHub Workflow Lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0 # ✅ Fix for Super Linter SHA access
911
- name: Super Linter
1012
uses: github/super-linter@v6
1113
env:

.github/workflows/SBOM Generator.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: [main]
66
workflow_dispatch:
7-
87
jobs:
98
generate-sbom:
109
runs-on: ubuntu-latest
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
---
12
name: 🧪 SBOM Attestation
23
on:
34
workflow_dispatch:
4-
55
jobs:
66
attest:
77
runs-on: ubuntu-latest
@@ -10,4 +10,4 @@ jobs:
1010
- run: make sbom-py
1111
- run: make sbom-image
1212
- run: make audit
13-
- run: python .hooks/check-audit-artifacts.py
13+
- run: python .hooks/check-audit-artifacts.py

.github/workflows/Sbom Image Scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
---
12
name: 📦 SBOM Image Scan
23
on:
34
workflow_dispatch:
45
push:
56
branches: [main]
6-
77
jobs:
88
image-sbom:
99
runs-on: ubuntu-latest
@@ -18,4 +18,4 @@ jobs:
1818
- uses: actions/upload-artifact@v4
1919
with:
2020
name: sbom-image
21-
path: sbom.spdx.json
21+
path: sbom.spdx.json

.github/workflows/Vulnerability Audit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ jobs:
3535
path: pip-audit.json
3636
retention-days: 30
3737
- name: Show pip-audit version
38-
run: pip freeze | grep pip-audit
38+
run: |-
39+
echo "### pip-audit version" >> $GITHUB_STEP_SUMMARY
40+
pip show pip-audit || echo "⚠️ pip-audit not found via pip show" >> $GITHUB_STEP_SUMMARY

.hooks/check-audit-artifacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
2-
import sys
32
import argparse
3+
import sys
44
from pathlib import Path
55

66

0 commit comments

Comments
 (0)