From 9328713ae5aa8846ec18c178fae84d1cf0951df4 Mon Sep 17 00:00:00 2001 From: Hiren Kangad Date: Thu, 21 May 2026 09:50:59 +0530 Subject: [PATCH] ci: publish multi-arch container image to GHCR Build linux/amd64 + linux/arm64 from the existing Dockerfile on every push to main, on git tags v*.*.*, and on manual workflow_dispatch. Pushes to ghcr.io/metalfinger/refboard with tags :latest (default branch), :sha-XXX (every push), and semver tags on releases. Uses GHA cache for speed. Tightens .dockerignore so multi-arch builds don't ship docs/, examples/, scripts/, .github/, or .docker-data into the image context. Co-Authored-By: Claude Opus 4.7 --- .dockerignore | 7 ++++ .github/workflows/publish-image.yml | 54 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/publish-image.yml diff --git a/.dockerignore b/.dockerignore index a9ae42c..503eaf4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,10 @@ **/node_modules **/.git **/.env +.github +.docker-data +docs +examples +scripts +*.md +!README.md diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 0000000..27dded2 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,54 @@ +name: Publish container image + +on: + push: + branches: [main] + tags: ['v*.*.*'] + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha,prefix=sha-,format=short + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max