From 60b2347c9172ad7d5379488c7760be78c12e9a38 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Thu, 5 Mar 2026 23:19:12 +0100 Subject: [PATCH] feat: push Docker image to GitHub Container Registry on release Replace generic registry secrets with ghcr.io using the built-in GITHUB_TOKEN. Use docker/metadata-action for automatic semver tagging. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 30 ++++++++++++++++-------------- CLAUDE.md | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1308533..dc0c5ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,31 +20,33 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Extract version from tag - id: version - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to Container Registry - if: env.REGISTRY_URL != '' + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ secrets.REGISTRY_URL }} - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_TOKEN }} - env: - REGISTRY_URL: ${{ secrets.REGISTRY_URL }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . - push: ${{ secrets.REGISTRY_URL != '' }} - tags: | - ${{ secrets.REGISTRY_URL && format('{0}/crumbs:{1}', secrets.REGISTRY_URL, steps.version.outputs.VERSION) || '' }} - ${{ secrets.REGISTRY_URL && format('{0}/crumbs:latest', secrets.REGISTRY_URL) || '' }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/CLAUDE.md b/CLAUDE.md index f60833b..3760b39 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,7 +80,7 @@ GitHub Actions with two workflows: 5. **Docker Build** — validates the Docker image builds (depends on step 3) **Release** (`.github/workflows/release.yml`) — runs on `v*` tags: -- Runs full CI pipeline, then builds + pushes Docker image to configured registry +- Runs full CI pipeline, then builds + pushes Docker image to `ghcr.io` (GitHub Container Registry) - Creates a GitHub Release with auto-generated notes **Docker**: Multi-stage Dockerfile (node:22-slim), exposes port 3000, persists data to `/data` volume.