Skip to content

Commit 9567e4d

Browse files
committed
Upload sbom artifacts
1 parent a0b4b7a commit 9567e4d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.github/actions/sbom/action.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ inputs:
55
image-ref:
66
description: The reference to the image for which the SBOM will be generated
77
required: true
8+
artifact-name:
9+
description: The name to use for the uploaded SBOM artifact (without extension)
10+
required: false
11+
default: sbom
812

913
outputs:
1014
sbom-path:
1115
description: The path to the generated SBOM file
1216
value: ${{ steps.generate-sbom.outputs.OUTPUT_PATH }}
17+
artifact-name:
18+
description: The name of the uploaded SBOM artifact (with extension)
19+
value: ${{ steps.generate-sbom.outputs.ARTIFACT_NAME }}
1320

1421
runs:
1522
using: "composite"
@@ -35,7 +42,17 @@ runs:
3542
$SYFT_CMD ${{ inputs.image-ref }} --select-catalogers "rpm,+sbom-cataloger" -o spdx-json=${OUTPUT_PATH}
3643
echo "OUTPUT_PATH=${OUTPUT_PATH}" >> $GITHUB_OUTPUT
3744
38-
- name: Add SBOM to release
39-
uses: anchore/sbom-action/publish-sbom@f8bdd1d8ac5e901a77a92f111440fdb1b593736b # v0
45+
NAME=${{ inputs.artifact-name }}
46+
# Remove consecutive dashes (when there's no variant, for example)
47+
NAME=${NAME//--/-}
48+
# Set ARTIFACT_NAME for use in artifact upload (replace / with _)
49+
echo "ARTIFACT_NAME=${NAME//\//_}.spdx.json" >> "$GITHUB_OUTPUT"
50+
51+
- name: Upload SBOM to Job Artifacts
52+
id: upload-sbom
53+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
4054
with:
41-
sbom-artifact-match: ${{ steps.generate-sbom.outputs.OUTPUT_PATH }}
55+
name: ${{ steps.generate-sbom.outputs.ARTIFACT_NAME }}
56+
path: ${{ steps.generate-sbom.outputs.OUTPUT_PATH }}
57+
if-no-files-found: error
58+
compression-level: 9

.github/workflows/build-image.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ jobs:
203203
if: ${{ inputs.generate-sbom == true && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event.pull_request.merged == true) }}
204204
with:
205205
image-ref: ${{ steps.build.outputs.image-ref }}@${{ steps.build.outputs.digest }}
206+
artifact-name: ${{ inputs.image-name }}-${{ inputs.variant }}-${{ matrix.platform }}
206207

207208
- uses: ./github-actions/.github/actions/sign
208209
name: Sign image

.github/workflows/create-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ jobs:
8383
tag_name: ${{ inputs.version }}
8484
body_path: ./changelog.md
8585
make_latest: true
86+
files: *.spdx.json

0 commit comments

Comments
 (0)