Skip to content

Commit d528449

Browse files
committed
Add sbom generation from collected data and upload artifact
1 parent 0156113 commit d528449

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.github/actions/shared-steps/action.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ runs:
439439
echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
440440
441441
# don't fail if this doesn't exist, we may not always generate it
442-
# sudo mv repo-metadata-*.txt $(basename ${image_file}).repo-metadata.txt || true
442+
sudo mv sbom-data-*.json $(basename ${image_file}).sbom-data.json || true
443443
444444
#- id: 'google-auth-dev-images'
445445
# if: env.IMAGE_TYPE == 'gcp'
@@ -519,9 +519,10 @@ runs:
519519
. ./.venv-sbom/bin/activate
520520
mkdir -p sbom
521521
shopt -s nullglob
522-
for f in sbom-data/sbom-data*.json; do
522+
for f in *.sbom-data.json; do
523+
echo "Generating SBOM document with $f"
523524
base=$(basename "$f" .json)
524-
python3 sbom-tools/sbom_generator.py "${base}" "$f" "${base}.spdx.json" -v
525+
python3 sbom-tools/sbom_generator.py "${base}" "$f" "${base}.sbom.spdx.json"
525526
done
526527
527528
# - name: Setup tmate session
@@ -620,12 +621,21 @@ runs:
620621

621622
- uses: actions/upload-artifact@v4
622623
name: Store repo metadata as artifact
623-
id: repo-meta-artifact
624+
id: sbom-data-artifact
624625
if: inputs.store_as_artifact == 'true'
625626
with:
626627
compression-level: 9
627-
name: ${{ env.IMAGE_NAME }}.repo-metadata.txt
628-
path: ${{ env.IMAGE_FILE }}.repo-metadata.txt
628+
name: ${{ env.IMAGE_NAME }}.sbom-data.json
629+
path: ${{ env.IMAGE_FILE }}.sbom-data.json
630+
631+
- uses: actions/upload-artifact@v4
632+
name: Store SBOM as artifact
633+
id: sbom-artifact
634+
if: inputs.store_as_artifact == 'true'
635+
with:
636+
compression-level: 9
637+
name: ${{ env.IMAGE_NAME }}.sbom.spdx.json
638+
path: ${{ env.IMAGE_FILE }}.sbom.spdx.json
629639

630640
- uses: actions/upload-artifact@v4
631641
name: Store checksum as artifact

almalinux_10_gcp.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ build {
117117
]
118118
}
119119

120-
# copy the repo metadata file into output
120+
# copy SBOM metadata file into output
121121
post-processor "shell-local" {
122122
inline = [
123-
"cp /tmp/repo-metadata-$PACKER_BUILD_NAME.txt output-$PACKER_BUILD_NAME/"
123+
"cp /tmp/sbom-data-$PACKER_BUILD_NAME.json output-$PACKER_BUILD_NAME/"
124124
]
125125
}
126126

ansible/roles/sbom_data/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
ansible.builtin.shell: python3 /dev/shm/sbom_data_collector.py -o /dev/shm/sbom-data.json -v
99
register: sbom_data_collector
1010

11-
- name: Write repo metadata for SBOMs to artifact file
11+
- name: Write SBOM data to artifact file
1212
ansible.builtin.fetch:
1313
src: /dev/shm/sbom-data.json
14-
dest: "{{ playbook_dir }}/../sbom-data/sbom-data-{{ packer_build_name }}.json"
14+
dest: "/tmp/sbom-data-{{ packer_build_name }}.json"
1515
flat: true
1616
become: false

0 commit comments

Comments
 (0)