Skip to content

Commit 9446c57

Browse files
authored
GHA: sign built tags (#59)
Similar to e.g. element-hq/synapse#16774
1 parent 2151f88 commit 9446c57

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/docker.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ on:
88

99
permissions:
1010
contents: read
11+
id-token: write # needed for signing the images with GitHub OIDC Token
1112

1213
jobs:
1314
build:
1415
runs-on: ubuntu-latest
1516
steps:
17+
- name: Install Cosign
18+
uses: sigstore/cosign-installer@v3
19+
1620
- name: Log in to DockerHub
1721
uses: docker/login-action@v2
1822
with:
@@ -29,10 +33,22 @@ jobs:
2933
type=pep440,pattern={{raw}}
3034
3135
- name: Build and push all platforms
36+
id: build-and-push
3237
uses: docker/build-push-action@v3
3338
with:
3439
push: true
3540
labels: "gitsha1=${{ github.sha }}"
3641
tags: "${{ steps.set-tag.outputs.tags }}"
3742
file: "docker/Dockerfile"
3843
platforms: linux/amd64
44+
45+
- name: Sign the images with GitHub OIDC Token
46+
env:
47+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
48+
TAGS: ${{ steps.set-tag.outputs.tags }}
49+
run: |
50+
images=""
51+
for tag in ${TAGS}; do
52+
images+="${tag}@${DIGEST} "
53+
done
54+
cosign sign --yes ${images}

0 commit comments

Comments
 (0)