From 1de426499de0f6eaec6bf5aac3bd6d482dee22bf Mon Sep 17 00:00:00 2001 From: devZenta Date: Mon, 29 Dec 2025 00:39:14 +0100 Subject: [PATCH] feat(ci): improve Docker workflow with Buildx, caching and semver tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .github/workflows/docker.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b9dc138..e9701e9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,14 @@ -name: Docker +name: Build and Publish Docker Image on: push: - branches: [main] + branches: + - main + tags: + - "v*" + pull_request: + branches: + - main env: REGISTRY: ghcr.io @@ -10,17 +16,20 @@ env: jobs: build-and-push: - name: Build & Push Docker Image runs-on: ubuntu-latest permissions: contents: read packages: write steps: - - name: Checkout code + - name: Checkout repository uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to Container Registry + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} @@ -33,13 +42,18 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=latest + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} type=sha,prefix= - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max