From 4aa1e1b32fe5d74daf4325d3ff61aa42adfbdece Mon Sep 17 00:00:00 2001 From: Rafael Reis Date: Sun, 8 Mar 2026 12:57:15 -0700 Subject: [PATCH] ci: build and publish Docker image to GHCR --- .github/workflows/docker-ghcr.yml | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docker-ghcr.yml diff --git a/.github/workflows/docker-ghcr.yml b/.github/workflows/docker-ghcr.yml new file mode 100644 index 0000000..acdea3a --- /dev/null +++ b/.github/workflows/docker-ghcr.yml @@ -0,0 +1,63 @@ +name: Docker Image (GHCR) + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + tags: + - 'v*' + +permissions: + contents: read + packages: write + +concurrency: + group: docker-ghcr-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + + - name: Build (and push on main/tags) + uses: docker/build-push-action@v6 + with: + context: . + file: docker/Dockerfile + platforms: linux/amd64,linux/arm64 + 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