From 09dcfde16e36007f39d0f4e9adf26eb1e1327f66 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 4 Apr 2026 01:37:09 -0400 Subject: [PATCH] ci: use docker/metadata-action and build-push-action Cleaner pipeline using official Docker actions. Supports semver tags alongside latest. Registry driven by vars.REGISTRY variable. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/deploy.yml | 57 ++++++++++++++++++------------------- README.md | 5 ++-- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 83a7e8e..5c60282 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -4,40 +4,37 @@ on: push: branches: - main + tags: + - 'v*' jobs: - build-and-push: + build-push: + name: Build & Push runs-on: ubuntu-latest + if: github.event_name == 'push' steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set image tags - id: image - run: | - # Gitea's container registry lives on the same host as the Gitea instance - REGISTRY="${{ gitea.server_url }}" - REGISTRY="${REGISTRY#https://}" - REGISTRY="${REGISTRY#http://}" - IMAGE="${REGISTRY}/josh/sixflagssupercalendar" - SHA="${{ gitea.sha }}" - echo "registry=${REGISTRY}" >> "$GITHUB_OUTPUT" - echo "tag_latest=${IMAGE}:latest" >> "$GITHUB_OUTPUT" - echo "tag_sha=${IMAGE}:${SHA::8}" >> "$GITHUB_OUTPUT" + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar + tags: | + type=semver,pattern={{version}} + type=raw,value=latest,enable={{is_default_branch}} - - name: Log in to registry - run: | - echo "${{ secrets.REGISTRY_TOKEN }}" | \ - docker login "${{ steps.image.outputs.registry }}" -u josh --password-stdin + - name: Log in to Gitea registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} - - name: Build image - run: | - docker build \ - -t "${{ steps.image.outputs.tag_latest }}" \ - -t "${{ steps.image.outputs.tag_sha }}" \ - . - - - name: Push image - run: | - docker push "${{ steps.image.outputs.tag_latest }}" - docker push "${{ steps.image.outputs.tag_sha }}" + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 4af30f4..c2b8b66 100644 --- a/README.md +++ b/README.md @@ -116,11 +116,10 @@ The pipeline is defined at [`.gitea/workflows/deploy.yml`](.gitea/workflows/depl | Type | Name | Value | |------|------|-------| +| Variable | `REGISTRY` | Registry hostname — `gitea.thewrightserver.net` | | Secret | `REGISTRY_TOKEN` | A Gitea access token with `package:write` scope | -Set this under **Repository → Settings → Actions → Secrets**. - -The registry host is derived automatically from `gitea.server_url` — no `REGISTRY_URL` variable needed. +Set these under **Repository → Settings → Actions → Variables / Secrets**. #### Upstream remote