| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- name: 'Provenance / SBOM / Sign'
- description: 'Creates SBOM & provenance files and signs the image'
- inputs:
- image-name:
- description: "name of the image"
- required: true
- default: ''
- image-tag:
- description: "image tag"
- required: true
- default: ""
- GHCR_USERNAME:
- description: "ghcr username"
- required: true
- GHCR_TOKEN:
- description: "ghcr token"
- required: true
- GITHUB_TOKEN:
- description: "gh token"
- required: true
- runs:
- using: "composite"
- steps:
- - name: Install cosign
- uses: sigstore/cosign-installer@v2
- with:
- cosign-release: v1.12.1
- - name: Install Syft
- uses: anchore/sbom-action/download-syft@v0.7.0
- - name: Check Cosign install
- shell: bash
- run: cosign version
- - name: Login to ghcr.io
- uses: docker/login-action@v1.14.1
- with:
- registry: ghcr.io
- username: ${{ inputs.GHCR_USERNAME }}
- password: ${{ inputs.GHCR_TOKEN }}
- - name: Setup Go
- uses: actions/setup-go@v3
- with:
- go-version-file: "go.mod"
- - name: Set up crane
- shell: bash
- run: go install github.com/google/go-containerregistry/cmd/crane@v0.11.0
- - name: Get docker image tag
- id: container_info
- shell: bash
- run: echo "::set-output name=digest::$(crane digest ${{ inputs.image-name }}:${{ inputs.image-tag }})"
- - name: Sign image
- shell: bash
- env:
- COSIGN_EXPERIMENTAL: "1"
- run: cosign sign -a GITHUB_ACTOR=${{ github.triggering_actor }} "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
- - name: Attach SBOM to image
- shell: bash
- env:
- COSIGN_EXPERIMENTAL: "1"
- run: |
- syft "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}" -o spdx-json=sbom-spdx.json
- cosign attest --predicate sbom-spdx.json --type spdx "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
- cosign verify-attestation --type spdx ${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }} | jq '.payload |= @base64d | .payload | fromjson'
- - name: Generate provenance
- uses: philips-labs/slsa-provenance-action@v0.7.2
- with:
- command: generate
- subcommand: container
- arguments: --repository "${{ inputs.image-name }}" --output-path provenance.att --digest "${{ steps.container_info.outputs.digest }}" --tags "${{ inputs.image-tag }}"
- env:
- COSIGN_EXPERIMENTAL: "0"
- GITHUB_TOKEN: "${{ inputs.GITHUB_TOKEN }}"
- - name: Attach provenance
- shell: bash
- env:
- COSIGN_EXPERIMENTAL: "1"
- run: |
- jq '.predicate' provenance.att > provenance-predicate.att
- cosign attest --predicate provenance-predicate.att --type slsaprovenance "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
- cosign verify-attestation --type slsaprovenance ${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}
|