|
| 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: 5 |
| 23 | + EXPECTED_VULNERABLE_PACKAGE: 0 |
| 24 | + EXPECTED_DEPENDENCY: 1 |
| 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: opencontainers/runc |
| 34 | + |
| 35 | + - name: Generate SBOM with cyclonedx-gomod |
| 36 | + uses: CycloneDX/gh-gomod-generate-sbom@v2 |
| 37 | + with: |
| 38 | + version: v1 |
| 39 | + args: mod -licenses -json -output gomod-sbom.cdx.json |
| 40 | + |
| 41 | + - name: Upload SBOM as GitHub Artifact |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: sbom-report |
| 45 | + path: "gomod-sbom.cdx.json" |
| 46 | + retention-days: 20 |
| 47 | + |
| 48 | + - name: Import SBOM into ScanCode.io |
| 49 | + uses: aboutcode-org/scancode-action@main |
| 50 | + with: |
| 51 | + pipelines: "load_sbom" |
| 52 | + inputs-path: "gomod-sbom.cdx.json" |
| 53 | + scancodeio-repo-branch: "main" |
| 54 | + |
| 55 | + - name: Verify SBOM Analysis Results in ScanCode.io |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + scanpipe verify-project \ |
| 59 | + --project scancode-action \ |
| 60 | + --packages ${{ env.EXPECTED_PACKAGE }} \ |
| 61 | + --vulnerable-packages ${{ env.EXPECTED_VULNERABLE_PACKAGE }} \ |
| 62 | + --dependencies ${{ env.EXPECTED_DEPENDENCY }} |
0 commit comments