-
Notifications
You must be signed in to change notification settings - Fork 18
88 lines (81 loc) · 2.62 KB
/
reusable-sbom.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Generate and push an SBOM dependency list
on:
workflow_call:
inputs:
project_name:
type: string
description: "Project name to report to dependency track"
required: true
artifact-prefix:
type: string
description: "what to prefix the artifacts with e.g. int-"
default: ""
secrets:
dependency_track_url:
description: "Base URL of the dependency track instance"
required: true
dependency_track_api_key:
description: "API key to use for sending data to dependency track"
required: true
jobs:
generate-and-push-sbom:
runs-on: 'ubuntu-latest'
# env:
# HEADLESS: true
# RAILS_TEST_DB_NAME: 'postgres'
# RAILS_TEST_DB_USERNAME: 'postgres'
# RAILS_TEST_DB_PASSWORD: 'postgres'
# RAILS_ENV: 'test'
# CI: 'true'
# PGDATESTYLE: German
#
# services:
# postgres:
# image: 'postgres:11'
# env:
# POSTGRES_PASSWORD: 'postgres'
# ports: [ '5432:5432' ]
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 10s
# --health-retries 10
# memcached:
# image: 'memcached'
# ports: [ '11211:11211' ]
steps:
- uses: actions/checkout@v4
- name: 'Generate SBOM for ruby and npm dependencies'
run: |
npm install -g @cyclonedx/cdxgen
cdxgen -o ./sbom-ruby.json -t ruby .
cdxgen -o ./sbom-npm.json -t npm .
- name: 'Merge frontend and backend SBOMs'
run: |
docker run \
--rm \
-v $(pwd):/data \
cyclonedx/cyclonedx-cli \
merge \
--input-files data/sbom-ruby.json data/sbom-npm.json \
--output-file data/sbom.xml
- name: 'Push merged SBOM to dependency track'
run: |
curl --verbose \
-s \
--location \
--request POST ${{ secrets.dependency_track_url }}/api/v1/bom \
--header "X-Api-Key: ${{ secrets.dependency_track_api_key }}" \
--header "Content-Type: multipart/form-data" \
--form "autoCreate=true" \
--form "projectName=${{ inputs.project_name }}" \
--form "projectVersion=latest" \
--form "[email protected]"
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ inputs.artifact-prefix }}sboms
path: |
./sbom-npm.json
./sbom-ruby.json
./sbom.xml