Skip to content

Commit aacaa21

Browse files
committed
Sign published image manifests with cosign
Add keyless cosign signing for the published multi-arch manifests, including the canonical version tags and latest. The workflow now requests the OIDC token permission needed for GitHub-backed signing and signs the final manifest digests after publication.
1 parent 6f07c01 commit aacaa21

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/build.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ on:
2121
env:
2222
IMAGE_NAME: ${{ inputs.image_name || vars.IMAGE_NAME || 'nikolaik/python-nodejs' }}
2323

24+
permissions:
25+
contents: write
26+
id-token: write
27+
2428
jobs:
2529
generate-matrix:
2630
name: Generate build matrix
@@ -112,15 +116,21 @@ jobs:
112116
password: ${{ secrets.DOCKERHUB_TOKEN }}
113117

114118
- name: Push multi-arch manifest
115-
run: docker manifest push "${IMAGE_NAME}:${{ matrix.key }}"
119+
id: push-manifest
120+
run: |
121+
digest="$(docker manifest push "${IMAGE_NAME}:${{ matrix.key }}" | tail -n1)"
122+
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
116123
117-
- name: Set up Docker Buildx
118-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
124+
- name: Install Cosign
125+
uses: sigstore/cosign-installer@v4.0.0
126+
127+
- name: Sign multi-arch manifest
128+
run: cosign sign --yes "${IMAGE_NAME}@${{ steps.push-manifest.outputs.digest }}"
119129

120130
- name: Add digest to build context
121131
run: |
122132
mkdir builds/
123-
digest="$(docker buildx imagetools inspect "${IMAGE_NAME}:${{ matrix.key }}" | awk '/^Digest:/ {print $2}')"
133+
digest="${{ steps.push-manifest.outputs.digest }}"
124134
echo '${{ toJSON(matrix) }}' | jq --arg digest "$digest" '. +={"digest": $digest}' >> "builds/${{ matrix.key }}.json"
125135
126136
- name: Upload build context

0 commit comments

Comments
 (0)