Skip to content

Commit 4162fac

Browse files
committed
add workflow to tag latest image on release
1 parent 272744b commit 4162fac

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish Docker latest tag
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
tag-docker-latest:
9+
# Only run when the release is marked as "Latest release" in the GitHub UI
10+
if: github.event.release.make_latest == 'true'
11+
runs-on: [self-hosted, Linux]
12+
13+
env:
14+
GHCR_REPO: ghcr.io/defguard/defguard-proxy
15+
16+
permissions:
17+
packages: write
18+
id-token: write # needed for Cosign keyless signing
19+
20+
steps:
21+
- name: Install Cosign
22+
uses: sigstore/cosign-installer@v4.1.1
23+
24+
- name: Login to GitHub container registry
25+
uses: docker/login-action@v4
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v4
33+
34+
- name: Derive semver tag
35+
run: |
36+
# Strip the leading 'v' from the release tag name (e.g. v1.2.3 -> 1.2.3)
37+
VERSION="${{ github.event.release.tag_name }}"
38+
echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
39+
40+
- name: Tag image as latest
41+
run: |
42+
docker buildx imagetools create \
43+
--tag ${{ env.GHCR_REPO }}:latest \
44+
${{ env.GHCR_REPO }}:${{ env.VERSION }}
45+
46+
- name: Sign the latest tag with GitHub OIDC Token
47+
run: cosign sign --yes ${{ env.GHCR_REPO }}:latest
48+
49+
- name: Verify image signature
50+
run: |
51+
cosign verify ${{ env.GHCR_REPO }}:latest \
52+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
53+
--certificate-identity-regexp="https://github.com/DefGuard/proxy" \
54+
-o text

0 commit comments

Comments
 (0)