|
16 | 16 | permissions: |
17 | 17 | contents: read |
18 | 18 | packages: write |
| 19 | + id-token: write # mint the OIDC token the attestation is signed with |
| 20 | + attestations: write # write the build-provenance attestation (the "claim") |
19 | 21 | steps: |
20 | 22 | - name: Checkout repository |
21 | 23 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
|
41 | 43 | sudo nerdctl build -f Containerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} . |
42 | 44 | sudo nerdctl tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
43 | 45 | - name: Push image |
| 46 | + id: push |
44 | 47 | run: | |
45 | 48 | sudo nerdctl push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} |
46 | 49 | sudo nerdctl push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 50 | + # nerdctl push has no --digestfile, so read the real sha256 back from |
| 51 | + # the registry with skopeo (pre-installed on ubuntu-latest). This is |
| 52 | + # the digest the registry actually holds for the pushed tag. |
| 53 | + DIGEST="$(skopeo inspect --format '{{.Digest}}' \ |
| 54 | + --creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \ |
| 55 | + docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }})" |
| 56 | + echo "digest=$DIGEST" >> "$GITHUB_OUTPUT" |
| 57 | + # GitHub native artifact attestation (build provenance) for the pushed |
| 58 | + # image. Verify with: |
| 59 | + # gh attest verify oci://ghcr.io/${{ github.repository }}:<tag> \ |
| 60 | + # --repo ${{ github.repository }} |
| 61 | + - name: Attest container provenance |
| 62 | + uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2 |
| 63 | + with: |
| 64 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 65 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 66 | + push-to-registry: true |
47 | 67 | - name: Tag release version |
48 | 68 | if: github.event_name == 'release' |
49 | 69 | run: | |
|
0 commit comments