Skip to content

Commit

Permalink
ci: enable SBOM generation and attestation in 'Build and push' reusab…
Browse files Browse the repository at this point in the history
…le workflow

This enables SBOM generation for the release and ci workflows.

Grype can make use of the SBOM to scan for vulnerabilities
  • Loading branch information
karelvanhecke committed Jun 5, 2024
1 parent 89f4356 commit 4ee807d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,32 @@ jobs:
- name: Start podman daemon
run: systemctl --user start podman.socket

- name: Scan image with Grype
- name: Generate SBOM
uses: anchore/sbom-action@e8d2a6937ecead383dfe75190d104edd1f9c5751 # v0.16.0
with:
syft-version: v1.5.0
image: podman:${{ steps.push.outputs.registry-path }}@${{ steps.push.outputs.digest }}
upload-artifact: false
upload-release-assets: false
format: json
output-file: ${{ inputs.image }}-${{ inputs.version }}.syft.json

- name: Create SBOM attestation
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
run: >-
cosign attest --yes --key env://COSIGN_PRIVATE_KEY
--registry-password='${{ secrets.GITHUB_TOKEN }}'
--registry-username='${{ github.actor }}'
--predicate='${{ inputs.image }}-${{ inputs.version }}.syft.json'
${{ inputs.registry }}/${{ steps.build.outputs.image }}@${{ steps.push.outputs.digest }}
- name: Scan SBOM with Grype
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a # v3.6.4
id: scan
with:
image: podman:${{ steps.push.outputs.registry-path }}@${{ steps.push.outputs.digest }}
sbom: ${{ inputs.image }}-${{ inputs.version }}.syft.json
fail-build: false
output-format: sarif
only-fixed: true
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ jobs:
releasever=$(yq '.releasever' almalinux-bootc-version.yaml)
echo "version=${releasever}+$GITHUB_SHA" >> "$GITHUB_OUTPUT"
tags="$GITHUB_REF_NAME $GITHUB_SHA"
tags="$GITHUB_SHA $GITHUB_REF_NAME v$releasever"
if [[ $GITHUB_REF_NAME == "main" ]]
then
tags+=" v${releasever%%.*}"
fi
echo "tags=$tags" >> "$GITHUB_OUTPUT"
build-push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
releasever=$(yq '.releasever' almalinux-bootc-version.yaml)
echo "version=${GITHUB_REF_NAME#v*}" >> "$GITHUB_OUTPUT"
tags="${GITHUB_REF_NAME%%.*} ${GITHUB_REF_NAME%.*} ${GITHUB_REF_NAME}"
tags="${GITHUB_REF_NAME} ${GITHUB_REF_NAME%.*} ${GITHUB_REF_NAME%%.*}"
echo "tags=$tags" >> "$GITHUB_OUTPUT"
build-push:
Expand Down

0 comments on commit 4ee807d

Please sign in to comment.