Skip to content

Commit 4b3e0cb

Browse files
feat(ci): attest build provenance (#287)
## Estate attestation rollout Adds GitHub native build-provenance attestation to `.github/workflows/ghcr-publish.yml`. **Push mechanism:** nerdctl (`nerdctl build` + `nerdctl push` to ghcr.io). This workflow pushes **two distinct artifacts**: the minimal image (`:${{ github.sha }}` / `:latest`, from `.containerization/Containerfile`) and the `:full` image (from `.containerization/Containerfile.full`). **How the digest is obtained:** `nerdctl push` has no `--digestfile` flag, so after the pushes the workflow reads each image's real `sha256:...` digest back from the registry with `skopeo inspect --format '{{.Digest}}'` (pre-installed on `ubuntu-latest`), authenticating with `GITHUB_TOKEN`. Because the minimal and full images are different artifacts with different digests, each gets its own attestation step. **Changes:** - The job already declared `id-token: write` + `attestations: write` — no permission change needed. - Captured the minimal and full image digests via `skopeo inspect`. - Added two `actions/attest-build-provenance@e8998f94…` (v2, pinned) steps (minimal + full), both with `push-to-registry: true`. Verify with: ``` gh attest verify oci://ghcr.io/hyperpolymath/echidna:<tag> --repo hyperpolymath/echidna ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 15aa05a commit 4b3e0cb

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/ghcr-publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,41 @@ jobs:
6565
sudo nerdctl build -f .containerization/Containerfile.full -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:full .
6666
6767
- name: Push images
68+
id: push
6869
run: |
6970
sudo nerdctl push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
7071
sudo nerdctl push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
7172
sudo nerdctl push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:full
73+
# nerdctl push has no --digestfile, so read the real sha256 of each
74+
# pushed image back from the registry with skopeo (pre-installed on
75+
# ubuntu-latest). The minimal (:sha/:latest) and :full images are
76+
# distinct artifacts, so each gets its own attestation.
77+
MIN_DIGEST="$(skopeo inspect --format '{{.Digest}}' \
78+
--creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
79+
docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }})"
80+
FULL_DIGEST="$(skopeo inspect --format '{{.Digest}}' \
81+
--creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
82+
docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:full)"
83+
echo "min_digest=$MIN_DIGEST" >> "$GITHUB_OUTPUT"
84+
echo "full_digest=$FULL_DIGEST" >> "$GITHUB_OUTPUT"
85+
86+
# GitHub native artifact attestation (build provenance) for the pushed
87+
# images. Verify with:
88+
# gh attest verify oci://ghcr.io/${{ github.repository }}:<tag> \
89+
# --repo ${{ github.repository }}
90+
- name: Attest container provenance (minimal image)
91+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
92+
with:
93+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
94+
subject-digest: ${{ steps.push.outputs.min_digest }}
95+
push-to-registry: true
96+
97+
- name: Attest container provenance (full image)
98+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
99+
with:
100+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
101+
subject-digest: ${{ steps.push.outputs.full_digest }}
102+
push-to-registry: true
72103

73104
- name: Tag release version
74105
if: github.event_name == 'release'

0 commit comments

Comments
 (0)