From 495f91690dcdc9bf7b7647b6fe1409891d2d4233 Mon Sep 17 00:00:00 2001 From: thethreemagi Date: Thu, 14 May 2026 20:39:42 +0100 Subject: [PATCH] Add reusable build-and-push workflow --- .gitea/workflows/build-and-push.yml | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .gitea/workflows/build-and-push.yml diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml new file mode 100644 index 0000000..59226e3 --- /dev/null +++ b/.gitea/workflows/build-and-push.yml @@ -0,0 +1,80 @@ +# Reusable workflow — called by project repos via `uses:` +# Requires Gitea 1.21+ for workflow_call support. +# Runner assumed on Pi 5 (ARM64 native) — no QEMU needed. +# If runner moves to x86 NAS, uncomment the QEMU setup steps. + +name: Build and push Docker image + +on: + workflow_call: + inputs: + image_name: + description: "Image name (no registry prefix)" + required: true + type: string + dockerfile_path: + description: "Path to Dockerfile" + required: false + type: string + default: "Dockerfile" + platforms: + description: "Target platform(s)" + required: false + type: string + default: "linux/arm64" + registry: + description: "Container registry host" + required: false + type: string + default: "git.thewichersfamily.com" + registry_owner: + description: "Registry namespace" + required: false + type: string + default: "thethreemagi" + secrets: + REGISTRY_USER: + required: true + REGISTRY_TOKEN: + required: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # Uncomment if runner is on x86 NAS (cross-compiling for Pi ARM64): + # - 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 Gitea registry + uses: docker/login-action@v3 + with: + registry: ${{ inputs.registry }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha,prefix=sha-,format=short + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ${{ inputs.dockerfile_path }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ inputs.platforms }} + cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }}:buildcache + cache-to: type=registry,ref=${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }}:buildcache,mode=max