Skip to content

Commit 72a824a

Browse files
committed
Add docker image publish workflow
1 parent ac8c623 commit 72a824a

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/publish.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-24.04
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
steps:
24+
# https://github.com/actions/checkout
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
# https://github.com/docker/login-action
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
# https://github.com/docker/metadata-action
37+
- name: Extract metadata (tags, labels) for Docker
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=semver,pattern={{major}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=semver,pattern={{version}}
46+
type=raw,value=latest,enable={{is_default_branch}}
47+
48+
# https://github.com/docker/build-push-action
49+
- name: Build and push Docker image
50+
id: push
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
58+
# https://github.com/actions/attest-build-provenance
59+
- name: Generate artifact attestation
60+
uses: actions/attest-build-provenance@v1
61+
with:
62+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
63+
subject-digest: ${{ steps.push.outputs.digest }}
64+
push-to-registry: true

0 commit comments

Comments
 (0)