Skip to content

Commit cd5ef94

Browse files
author
Cosimo Commisso
committed
add sbom signing workflow
1 parent 8fc8c46 commit cd5ef94

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Generate and Sign SBOM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
env:
13+
SBOM_OUTPUT: sbom-source.json
14+
15+
jobs:
16+
generate-sbom:
17+
name: Generate SBOM
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout source
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.21'
27+
28+
- name: Generate SBOM
29+
uses: CycloneDX/gh-gomod-generate-sbom@v2
30+
with:
31+
version: v1
32+
args: mod -licenses -json -output-version 1.6 -output sbom-validator.${{ github.ref_name }}.cdx.json
33+
34+
- name: Upload SBOM artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: unsigned-sbom
38+
path: sbom-validator.${{ github.ref_name }}.cdx.json
39+
40+
sign-and-archive-sbom:
41+
name: Sign and Archive SBOM
42+
needs: generate-sbom
43+
runs-on: ubuntu-latest
44+
env:
45+
SIGN_API_URL: https://secure-sbom-api-demo-slc-gateway-dhncnyq8.uc.gateway.dev/signdx
46+
SECURE_SBOM_KEY_ID: ${{ secrets.SECURE_SBOM_KEY_ID }}
47+
48+
steps:
49+
- name: Download unsigned SBOM artifact
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: unsigned-sbom
53+
54+
- name: Sign SBOM using Secure SBOM API
55+
run: |
56+
curl --fail -s -X POST ${SIGN_API_URL}?signtype=simple \
57+
-F "key_id=${SECURE_SBOM_KEY_ID}" \
58+
-F "sbom=@sbom-validator.${{ github.ref_name }}.cdx.json" \
59+
-o sbom-validator.${{ github.ref_name }}.cdx.signed.json
60+
61+
- name: Upload signed SBOM
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: signed-sbom
65+
path: sbom-validator.${{ github.ref_name }}.cdx.signed.json
66+
retention-days: 7

0 commit comments

Comments
 (0)