Building software with reusable workflows and artifact attestations can streamline your supply chain security and help you achieve SLSA v1.0 Build Level 3.
Before starting this guide, you should be familiar with:
First, we need to build with both artifact attestations and a reusable workflow.
If you aren't already using reusable workflows to build your software, you'll need to take your build steps and move them into a reusable workflow.
The reusable workflow you use to build your software must also generate artifact attestations to establish build provenance.
When you use a reusable workflow to generate artifact attestations, both the calling workflow and the reusable workflow need to have the following permissions.
permissions:
attestations: write
contents: read
id-token: write
If you are building container images, you will also need to include the packages: write permission.
To verify the artifact attestations generated with your builds, you can use gh attestation verify from the GitHub CLI.
The gh attestation verify command requires either --owner or --repo flags to be used with it. These flags do two things.
gh attestation verify where to fetch the attestation from. This will always be your caller workflow.gh attestation verify where the workflow that did the signing came from. This will always be the workflow that uses the attest action, which may be a reusable workflow.You can use optional flags with the gh attestation verify command.
--signer-repo flag to specify the repository that contains the reusable workflow.--signer-workflow flag to indicate the workflow file that should be used.For example, if your calling workflow is ORGANIZATION_NAME/REPOSITORY_NAME/.github/workflows/calling.yml and it uses REUSABLE_ORGANIZATION_NAME/REUSABLE_REPOSITORY_NAME/.github/workflows/reusable.yml you could do:
gh attestation verify -o ORGANIZATION_NAME --signer-repo REUSABLE_ORGANIZATION_NAME/REUSABLE_REPOSITORY_NAME PATH/TO/YOUR/BUILD/ARTIFACT-BINARY
Or if you want to specify the exact workflow:
gh attestation verify -o ORGANIZATION_NAME --signer-workflow REUSABLE_ORGANIZATION_NAME/REUSABLE_REPOSITORY_NAME/.github/workflows/reusable.yml PATH/TO/YOUR/BUILD/ARTIFACT-BINARY