Skip to content

Support subject-digest with multiple entries (comma separator or line separator) #162

Description

@v1v

I want to generate the build provenance for a multi-arch container image. Rather than using the docker build GitHub action in conjunction with the metadata-action, I use goreleaser.

Unfortunately, I cannot pass a multiline subject-digest but must run the same step as many container images are created.

For instance:

    - name: generate build provenance (binaries)
      uses: github-early-access/generate-build-provenance@main
      with:
        subject-path: "${{ github.workspace }}/tools/my-cli/dist/*.*"

    - name: container image digest
      id: image
      run: |
        set -euo pipefail
        # Gather the container image generated with goreleaser
        image=$(jq -r '.[] | select (.type=="Docker Image") | .path' tools/my-cli/dist/artifacts.json | cut -d':' -f1 | uniq )
        # Fetch the digest for the container image (amd64 and arm64)
        digest_1=$(docker images --format "{{.Digest}}" --no-trunc $image | sed -n 1p)
        digest_2=$(docker images --format "{{.Digest}}" --no-trunc $image | sed -n 2p)
        echo "name=$image" >> "$GITHUB_OUTPUT"
        echo "digest_1=$digest_1" >> "$GITHUB_OUTPUT"
        echo "digest_2=$digest_2" >> "$GITHUB_OUTPUT"

    - name: generate build provenance (containers ARM64)
      uses: github-early-access/generate-build-provenance@main
      with:
        subject-name: ${{ steps.image.outputs.name }}
        subject-digest: ${{ steps.image.outputs.digest_1 }}

    - name: generate build provenance (containers AMD64)
      uses: github-early-access/generate-build-provenance@main
      with:
        subject-name: ${{ steps.image.outputs.name }}
        subject-digest: ${{ steps.image.outputs.digest_2 }}

While I'd like to do something like:

    - name: generate build provenance (binaries)
      uses: github-early-access/generate-build-provenance@main
      with:
        subject-path: "${{ github.workspace }}/tools/my-cli/dist/*.*"

    - name: container image digest
      id: image
      run: |
        set -euo pipefail
        # Gather the container image generated with goreleaser
        image=$(jq -r '.[] | select (.type=="Docker Image") | .path' tools/my-cli/dist/artifacts.json | cut -d':' -f1 | uniq )
        # Fetch the digest for the container image (amd64 and arm64)
        digests=$(docker images --format "{{.Digest}}" --no-trunc $image)
        echo "name=$image" >> "$GITHUB_OUTPUT"
        echo "digests=$digests" >> "$GITHUB_OUTPUT"

    - name: generate build provenance (containers)
      uses: github-early-access/generate-build-provenance@main
      with:
        subject-name: ${{ steps.image.outputs.name }}
        subject-digests: ${{ steps.image.outputs.digests }}

if subject-digests could be a new input, or subject-digest could support a multiline value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions