Skip to content

Commit 12025b4

Browse files
committed
feat: workflow cleanup
1 parent 32aaf80 commit 12025b4

File tree

2 files changed

+75
-29
lines changed

2 files changed

+75
-29
lines changed

.github/workflows/release.yml

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ jobs:
3939
run: |
4040
echo "### 🚀 Release Completed" >> $GITHUB_STEP_SUMMARY
4141
echo "- ✅ GoReleaser successfully published binaries and SBOM" >> $GITHUB_STEP_SUMMARY
42-
sbom:
43-
name: 🔏 Generate & Sign SBOM
42+
43+
generate_sbom:
44+
name: 🔏 Generate SBOM
4445
runs-on: ubuntu-latest
4546
needs: goreleaser
4647

@@ -73,24 +74,55 @@ jobs:
7374
- name: Upload SBOM Artifacts
7475
uses: actions/upload-artifact@v4
7576
with:
76-
name: signed-sbom
77-
path: sbom-validator.${{ github.ref_name }}.cdx.signed.json
78-
79-
- name: Upload Signed SBOM to Release
80-
uses: softprops/action-gh-release@v2
81-
with:
82-
files: sbom-validator.${{ github.ref_name }}.cdx.signed.json
77+
name: unsigned-sbom
78+
path: sbom-validator.${{ github.ref_name }}.cdx.json
79+
retention-days: 7
8380

8481
- name: Add Job Summary
8582
run: |
8683
echo "### 🔏 SBOM Generated & Signed" >> $GITHUB_STEP_SUMMARY
8784
echo "- ✅ CycloneDX SBOM created" >> $GITHUB_STEP_SUMMARY
8885
echo "- 🔐 Signed with SecureSBOM API" >> $GITHUB_STEP_SUMMARY
8986
echo "- 📦 Uploaded as release asset" >> $GITHUB_STEP_SUMMARY
87+
88+
sign-sbom:
89+
name: Sign SBOM via SecureSBOM
90+
needs: generate_sbom
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- name: Checkout Repo
95+
uses: actions/checkout@v4
96+
97+
- name: Download Signed SBOM
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: unsigned-sbom
101+
path: .
90102

103+
- name: Sign SBOM via SecureSBOM
104+
uses: shiftleftcyber/secure-sbom-action@v1.3.1
105+
with:
106+
sbom_file: sbom-validator.${{ github.ref_name }}.cdx.json
107+
secure_sbom_action: sign
108+
api_key: ${{ secrets.SECURE_SBOM_API_KEY }}
109+
key_id: ${{ secrets.SECURE_SBOM_KEYID }}
110+
111+
- name: Upload Signed SBOM
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: signed-sbom
115+
path: sbom-validator.${{ github.ref_name }}.cdx.signed.json
116+
retention-days: 7
117+
118+
- name: Upload Signed SBOM to Release
119+
uses: softprops/action-gh-release@v2
120+
with:
121+
files: sbom-validator.${{ github.ref_name }}.cdx.signed.json
122+
91123
osv-scan:
92-
name: 🔎 OSV Scan (Signed SBOM)
93-
needs: sbom
124+
name: 🔎 OSV Scan
125+
needs: generate_sbom
94126
runs-on: ubuntu-latest
95127
permissions:
96128
security-events: write
@@ -104,32 +136,46 @@ jobs:
104136
- name: Download Signed SBOM
105137
uses: actions/download-artifact@v4
106138
with:
107-
name: signed-sbom
139+
name: unsigned-sbom
108140
path: .
109141

110142
- name: Run OSV Scanner
111143
run: |
112-
docker run --rm -v ${{ github.workspace }}:/scan ghcr.io/google/osv-scanner:latest \
113-
scan /scan/sbom-validator.${{ github.ref_name }}.cdx.signed.json \
144+
docker run --rm -v ${{ github.workspace }}:/opt --workdir /opt ghcr.io/google/osv-scanner:latest \
145+
scan --lockfile sbom-validator.${{ github.ref_name }}.cdx.json \
114146
--format json --output osv-scan-report.json || true
115147
116148
- name: Upload OSV Report
117149
uses: actions/upload-artifact@v4
118150
with:
119151
name: osv-scan-report
120152
path: osv-scan-report.json
121-
122-
# osv-scan:
123-
# name: 🔎 OSV Scan (Signed SBOM)
124-
# needs: sbom
125-
# uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.2.3"
126-
# with:
127-
# download-artifact: signed-sbom
128-
# scan-args: |-
129-
# --format json
130-
# --output osv-scan-report.json
131-
# sbom-validator.${{ github.ref_name }}.cdx.signed.json
132-
# permissions:
133-
# security-events: write
134-
# contents: read
135-
# actions: read
153+
154+
- name: Enforce Security Gate
155+
id: enforce-gate
156+
run: |
157+
echo "🔍 Evaluating OSV scan results..."
158+
COUNT=$(jq '[.results[] | select(.severity == "HIGH" or .severity == "CRITICAL")] | length' osv-scan-report.json)
159+
if [ "$COUNT" -gt 0 ]; then
160+
echo "❌ Blocking release - $COUNT high/critical vulnerabilities detected!"
161+
jq '.results[] | select(.severity == "HIGH" or .severity == "CRITICAL") | {package: .package.name, severity: .severity, summary: .summary}' osv-scan-report.json
162+
echo "blocked=true" >> $GITHUB_OUTPUT
163+
exit 1
164+
else
165+
echo "✅ No blocking vulnerabilities found."
166+
echo "blocked=false" >> $GITHUB_OUTPUT
167+
fi
168+
169+
- name: Add Job Summary
170+
if: always()
171+
run: |
172+
echo "### 🔒 OSV Vulnerability Scan Summary" >> $GITHUB_STEP_SUMMARY
173+
echo "- **Scan file:** \`osv-scan-report.json\`" >> $GITHUB_STEP_SUMMARY
174+
if [[ '${{ steps.enforce-gate.outputs.blocked }}' == 'true' ]]; then
175+
echo "- ❌ **High/Critical vulnerabilities found — release blocked**" >> $GITHUB_STEP_SUMMARY
176+
else
177+
echo "- ✅ **No blocking vulnerabilities detected — safe to proceed**" >> $GITHUB_STEP_SUMMARY
178+
fi
179+
echo "" >> $GITHUB_STEP_SUMMARY
180+
echo "For full report, download the [osv-scan-report artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
181+

0 commit comments

Comments
 (0)