Skip to content

Commit

Permalink
GHA: sign built tags (#59)
Browse files Browse the repository at this point in the history
Similar to e.g. element-hq/synapse#16774
  • Loading branch information
benbz authored May 22, 2024
1 parent 2151f88 commit 9446c57
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ on:

permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@v3

- name: Log in to DockerHub
uses: docker/login-action@v2
with:
Expand All @@ -29,10 +33,22 @@ jobs:
type=pep440,pattern={{raw}}
- name: Build and push all platforms
id: build-and-push
uses: docker/build-push-action@v3
with:
push: true
labels: "gitsha1=${{ github.sha }}"
tags: "${{ steps.set-tag.outputs.tags }}"
file: "docker/Dockerfile"
platforms: linux/amd64

- name: Sign the images with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.set-tag.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}

0 comments on commit 9446c57

Please sign in to comment.