Skip to content

Commit 26d8e85

Browse files
vanadium23claude
andcommitted
feat(ci): add GHCR build workflow for intermediate versions
- Builds on every push to any branch and on tags - Tags: branch-sha for branches (e.g. main-abc1234) - Tags: semver for releases (e.g. v1.0.0, latest) - Allows deploying intermediate versions to homelab Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 94a4fb4 commit 26d8e85

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/ghcr.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build and Push to GHCR
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build:
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 Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to 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+
- name: Extract metadata (tags, labels)
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
# For tags: v1.0.0 -> v1.0.0, latest
43+
type=semver,pattern={{version}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
46+
# For branches: feature/foo -> feature-foo-sha, main -> main-sha
47+
type=ref,event=branch,suffix=-{{sha}}
48+
# For PRs: pr-123
49+
type=ref,event=pr
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
build-args: |
59+
KOMPANION_VERSION=${{ github.ref_name }}-${{ github.sha }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)