Skip to content

Commit 1de4264

Browse files
devZentaclaude
andcommitted
feat(ci): improve Docker workflow with Buildx, caching and semver tags
- Add Docker Buildx for multi-arch support - Enable GitHub Actions cache for faster builds - Add semver tagging for version releases (v*) - Build on PRs without pushing (validation only) - Add conditional push based on event type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4718973 commit 1de4264

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/docker.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
name: Docker
1+
name: Build and Publish Docker Image
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- main
612

713
env:
814
REGISTRY: ghcr.io
915
IMAGE_NAME: ${{ github.repository }}
1016

1117
jobs:
1218
build-and-push:
13-
name: Build & Push Docker Image
1419
runs-on: ubuntu-latest
1520
permissions:
1621
contents: read
1722
packages: write
1823

1924
steps:
20-
- name: Checkout code
25+
- name: Checkout repository
2126
uses: actions/checkout@v4
2227

28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
2331
- name: Log in to Container Registry
32+
if: github.event_name != 'pull_request'
2433
uses: docker/login-action@v3
2534
with:
2635
registry: ${{ env.REGISTRY }}
@@ -33,13 +42,18 @@ jobs:
3342
with:
3443
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3544
tags: |
36-
type=raw,value=latest
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=semver,pattern={{version}}
48+
type=semver,pattern={{major}}.{{minor}}
3749
type=sha,prefix=
3850
3951
- name: Build and push Docker image
4052
uses: docker/build-push-action@v6
4153
with:
4254
context: .
43-
push: true
55+
push: ${{ github.event_name != 'pull_request' }}
4456
tags: ${{ steps.meta.outputs.tags }}
4557
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)