Skip to content

Commit

Permalink
Generate AtoM SBOM in CI
Browse files Browse the repository at this point in the history
Add ability to generate and upload an AtoM SBOM to Dependency Track in
CI.

This CI workflow will autocreate a new Dependency Track project for AtoM
for any qa or stable branch this workflow is picked to. The projectName
will be set to "atom" and the project version will be the branch name.

Because the parentName is set to 'AtoM', this SBOM will be grouped under
an 'AtoM' project group which must be present in advance.
  • Loading branch information
sbreker committed Apr 4, 2024
1 parent 753044f commit 9e22f07
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/generate-sbom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Generate and upload SBOM

on:
push:
branches:
- qa/**
- stable/**

jobs:
generate-sbom:
runs-on: ubuntu-latest
container:
image: aquasec/trivy:latest
options: --entrypoint ""
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up cache
uses: actions/cache@v4
with:
path: .trivycache/
key: ${{ runner.os }}-trivy-${{ hashFiles('**/lockfiles') }}
restore-keys: |
${{ runner.os }}-trivy-
- name: Generate SBOM
run: trivy fs --format cyclonedx --output sbom.xml .
env:
TRIVY_NO_PROGRESS: "true"

- name: Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.xml

upload-sbom:
needs: generate-sbom
runs-on: ubuntu-latest
steps:
- name: Download SBOM artifact
uses: actions/download-artifact@v4
with:
name: sbom

- name: Upload SBOM
run: |
curl -v -X 'POST' "${{ secrets.DEPENDENCY_TRACK_URL }}/api/v1/bom" \
-H "X-Api-Key: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}" \
-H "Content-Type: multipart/form-data" \
-F "autoCreate=true" \
-F "projectName=${{ github.repository }}" \
-F "projectVersion=${{ github.ref_name }}" \
-F "parentName=AtoM" \
-F "[email protected]"
env:
DEPENDENCY_TRACK_URL: ${{ secrets.DEPENDENCY_TRACK_URL }}
DEPENDENCY_TRACK_API_KEY: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}

0 comments on commit 9e22f07

Please sign in to comment.