# 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