From d1979ad50514233a7d871a14b9d90242c8d098c5 Mon Sep 17 00:00:00 2001 From: srinandan Date: Fri, 23 Aug 2024 21:47:36 +0000 Subject: [PATCH] chore: sbom and build attestations #527 --- .github/workflows/docker-publish.yml | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3250427f3..575a84031 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-latest permissions: - contents: read + contents: write # needed to publish sbom packages: write id-token: write attestations: write @@ -119,3 +119,31 @@ jobs: TAGS: ${{ steps.meta.outputs.tags }} run: | cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} + + - name: Generate SBOM + uses: anchore/sbom-action@v0 + with: + format: 'spdx-json' + output-file: 'sbom.spdx.json' + image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} + + - name: Publish SBOM + uses: anchore/sbom-action/publish-sbom@v0 + with: + sbom-artifact-match: ".*\\.spdx$" + + - name: Attest build provenance + uses: actions/attest-build-provenance@v1 + id: attest + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.build-and-push.outputs.digest }} + push-to-registry: true + + - name: Attest SBOM + uses: actions/attest-sbom@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.build-and-push.outputs.digest }} + sbom-path: 'sbom.spdx.json' + push-to-registry: true