Skip to content

Commit 1bf65e5

Browse files
Merge pull request #40 from umbraco/nul800sebastiaan-patch-1
Add GitHub Actions workflow for SBOM generation
2 parents a08e63a + 8a46eb9 commit 1bf65e5

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Generate SBOM for Dependency-Track
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- '*'
8+
9+
jobs:
10+
sbom:
11+
runs-on: ubuntu-latest
12+
env:
13+
SBOM_FILE: sbom/bom-frontend.xml
14+
TRACKER_ENDPOINT: "https://ca-live-global-dtrack-api.purplemoss-6e7d841c.westeurope.azurecontainerapps.io/api/v1/bom"
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '22.x'
24+
25+
- name: Install CycloneDX Node.js CLI in frontend
26+
run: |
27+
if [ -f "package.json" ]; then
28+
npm install --save-dev @cyclonedx/cyclonedx-npm
29+
else
30+
echo "ERROR: No package.json found — cannot generate SBOM."
31+
exit 1
32+
fi
33+
34+
- name: Generate SBOM for Node.js (frontend)
35+
run: |
36+
mkdir -p sbom
37+
if [ -f "package-lock.json" ] || [ -f "yarn.lock" ]; then
38+
npx @cyclonedx/cyclonedx-npm -o "$SBOM_FILE"
39+
else
40+
echo "ERROR: No package-lock.json or yarn.lock found — cannot create SBOM."
41+
exit 1
42+
fi
43+
44+
# enforce that CycloneDX really produced something
45+
if [ ! -f "$SBOM_FILE" ]; then
46+
echo "ERROR: SBOM file was not generated."
47+
exit 1
48+
fi
49+
50+
- name: Upload SBOM artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: frontend-sbom
54+
path: ${{ env.SBOM_FILE }}
55+
56+
- name: Upload Node.js SBOM to Dependency-Track
57+
env:
58+
DTRACK_API_KEY: ${{ secrets.DTRACK_API_KEY }}
59+
run: |
60+
curl --fail-with-body -v -i -w "\nHTTP Status: %{http_code}\n" \
61+
-X POST "$TRACKER_ENDPOINT" \
62+
-H "X-Api-Key: $DTRACK_API_KEY" \
63+
-H "accept: application/json" \
64+
-H "Content-Type: multipart/form-data" \
65+
-F "autoCreate=true" \
66+
-F "projectName=${{ github.event.repository.name }}-frontend" \
67+
-F "projectVersion=${{ github.ref_name }}" \
68+
-F "bom=@$SBOM_FILE"

0 commit comments

Comments
 (0)