Skip to content

Commit 72725fd

Browse files
committed
Add GHCR Docker publish workflow
1 parent b1cda8d commit 72725fd

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Docker image
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+
docker:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GHCR
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract image metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=tag
47+
type=sha
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: Build and push image
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
push: true
55+
platforms: linux/amd64,linux/arm64
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,24 @@ The compose service includes Docker log rotation using:
122122

123123
- `max-size: 10m`
124124
- `max-file: 3`
125+
126+
## Prebuilt Image (GHCR)
127+
128+
This repository includes a GitHub Actions workflow at `.github/workflows/docker-publish.yml`.
129+
130+
- On each push to `main`, it builds and publishes a multi-arch image to GHCR.
131+
- On tags like `v1.0.0`, it also publishes tag-based versions.
132+
- You can also run it manually from the Actions tab (`workflow_dispatch`).
133+
134+
Published image name:
135+
136+
```text
137+
ghcr.io/vdw/hetzner_ddns
138+
```
139+
140+
Run prebuilt image on a server:
141+
142+
```bash
143+
docker pull ghcr.io/vdw/hetzner_ddns:latest
144+
docker run -d --name hetzner-ddns --restart unless-stopped --env-file .env ghcr.io/vdw/hetzner_ddns:latest
145+
```

0 commit comments

Comments
 (0)