Skip to content

Commit 01f2114

Browse files
committed
Add workflow for the cyclonedx-gomod SCA integration
Signed-off-by: tdruez <[email protected]>
1 parent e22a24d commit 01f2114

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Generate SBOM with cyclonedx-gomod and load into ScanCode.io
2+
3+
# This workflow:
4+
# 1. Generates a CycloneDX SBOM for a container image using cyclonedx-gomod.
5+
# 2. Uploads the SBOM as a GitHub artifact for future inspection.
6+
# 3. Loads the SBOM into ScanCode.io for further analysis.
7+
# 4. Runs assertions to verify that the SBOM was properly processed in ScanCode.io.
8+
#
9+
# It runs on demand, and once a week (scheduled).
10+
11+
on:
12+
workflow_dispatch:
13+
schedule:
14+
# Run once a week (every 7 days) at 00:00 UTC on Sunday
15+
- cron: "0 0 * * 0"
16+
pull_request:
17+
18+
permissions:
19+
contents: read
20+
21+
env:
22+
EXPECTED_PACKAGE: 100
23+
EXPECTED_VULNERABLE_PACKAGE: 100
24+
EXPECTED_DEPENDENCY: 100
25+
26+
jobs:
27+
generate-and-load-sbom:
28+
runs-on: ubuntu-24.04
29+
steps:
30+
- name: Checkout minimal Go repo
31+
uses: actions/checkout@v4
32+
with:
33+
repository: rakyll/hello
34+
35+
# Download and invoke cyclonedx-gomod
36+
- name: Generate SBOM
37+
uses: CycloneDX/gh-gomod-generate-sbom@v2
38+
with:
39+
version: v1
40+
args: mod -licenses -json -output gomod-sbom.cdx.json
41+
42+
- name: Upload SBOM as GitHub Artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: sbom-report
46+
path: "gomod-sbom.cdx.json"
47+
retention-days: 20
48+
49+
- name: Import SBOM into ScanCode.io
50+
uses: aboutcode-org/scancode-action@main
51+
with:
52+
pipelines: "load_sbom"
53+
inputs-path: "gomod-sbom.cdx.json"
54+
scancodeio-repo-branch: "main"
55+
56+
- name: Verify SBOM Analysis Results in ScanCode.io
57+
shell: bash
58+
run: |
59+
scanpipe verify-project \
60+
--project scancode-action \
61+
--packages ${{ env.EXPECTED_PACKAGE }} \
62+
--vulnerable-packages ${{ env.EXPECTED_VULNERABLE_PACKAGE }} \
63+
--dependencies ${{ env.EXPECTED_DEPENDENCY }}

0 commit comments

Comments
 (0)