From 85f50bfc9668352d4a1b84fa28cadf1271c81cc5 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Sun, 21 Jun 2026 14:02:29 +1000 Subject: [PATCH] Add GitHub Actions workflow to build and publish image to GHCR Builds the production Docker image and pushes it to ghcr.io/dkam/clinch on pushes to main (edge + sha tags) and on v* release tags (vX.Y.Z, vX.Y, latest). amd64 only, with GHA layer caching. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..114c08b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Build and publish image + +on: + push: + branches: [ main ] + tags: [ 'v*' ] + +# Only one build per ref at a time; cancel superseded main builds. +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: ${{ github.ref == 'refs/heads/main' }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write # Required to push to GHCR + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=edge,branch=main + type=sha,prefix=sha-,format=short,enable={{is_default_branch}} + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + flavor: | + latest=auto + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max