Skip to content

Commit 649c667

Browse files
authored
Add attestation to built images (#2)
This PR adds attestation to the Docker images, allowing anyone to verify they were built within the GitHub Actions workflow. From [the GitHub docs](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds): > Artifact attestations enable you to create unfalsifiable provenance and integrity guarantees for the software you build. In turn, people who consume your software can verify where and how your software was built. > > When you generate artifact attestations with your software, you create cryptographically signed claims that establish your build's provenance and include the following information: > > - A link to the workflow associated with the artifact. > - The repository, organization, environment, commit SHA, and triggering event for the artifact. > - Other information from the OIDC token used to establish provenance. For more information, see [About security hardening with OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect).
1 parent def8bcf commit 649c667

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/build-image.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
branches: [ "main" ]
66

7+
permissions:
8+
contents: read
9+
packages: write
10+
id-token: write
11+
attestations: write
12+
713
env:
814
REGISTRY: ghcr.io
915
IMAGE_NAME: ${{ github.repository }}
@@ -27,9 +33,16 @@ jobs:
2733
- name: Set up Docker Buildx
2834
uses: docker/setup-buildx-action@v3
2935
- name: Build and push
36+
id: docker_build
3037
uses: docker/build-push-action@v6
3138
with:
3239
push: true
3340
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
3441
cache-from: type=gha
3542
cache-to: type=gha,mode=max
43+
- name: Generate artifact attestation
44+
uses: actions/attest-build-provenance@v2
45+
with:
46+
push-to-registry: true
47+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
subject-digest: ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)