mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add SBOM generation and attestation to GitHub workflow (#17277)
Move SBOM generation and attestation to GitHub workflow This PR moves the SBOM generation and attestation process from the `build_docker.sh` script to the GitHub workflow. The change: 1. Removes SBOM generation and attestation from the `build_docker.sh` script 2. Adds a new "SBOM Generation and Attestation" step in the GitHub workflow 3. Generates and attests SBOMs for both multi-arch images and latest tags when applicable This approach ensures SBOM generation happens once for the final multi-architecture image rather than for each architecture separately. Change-Id: I2e15d7322ddec933bbc9bd7880abba9b0842719f Signed-off-by: Thomas Kosiewski <tk@coder.com>
This commit is contained in:
@@ -1180,6 +1180,33 @@ jobs:
|
||||
done
|
||||
fi
|
||||
|
||||
- name: SBOM Generation and Attestation
|
||||
if: github.ref == 'refs/heads/main'
|
||||
env:
|
||||
COSIGN_EXPERIMENTAL: 1
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
|
||||
# Define image base and tags
|
||||
IMAGE_BASE="ghcr.io/coder/coder-preview"
|
||||
TAGS=("${{ steps.build-docker.outputs.tag }}" "main" "latest")
|
||||
|
||||
# Generate and attest SBOM for each tag
|
||||
for tag in "${TAGS[@]}"; do
|
||||
IMAGE="${IMAGE_BASE}:${tag}"
|
||||
SBOM_FILE="coder_sbom_${tag//[:\/]/_}.spdx.json"
|
||||
|
||||
echo "Generating SBOM for image: ${IMAGE}"
|
||||
syft "${IMAGE}" -o spdx-json > "${SBOM_FILE}"
|
||||
|
||||
echo "Attesting SBOM to image: ${IMAGE}"
|
||||
cosign clean "${IMAGE}"
|
||||
cosign attest --type spdxjson \
|
||||
--predicate "${SBOM_FILE}" \
|
||||
--yes \
|
||||
"${IMAGE}"
|
||||
done
|
||||
|
||||
# GitHub attestation provides SLSA provenance for the Docker images, establishing a verifiable
|
||||
# record that these images were built in GitHub Actions with specific inputs and environment.
|
||||
# This complements our existing cosign attestations which focus on SBOMs.
|
||||
|
||||
Reference in New Issue
Block a user