Rewrite reusable workflow with shell commands — no node dependency

This commit is contained in:
2026-05-18 03:19:01 +01:00
parent d24b36dfbb
commit b7334cfac2
+31 -41
View File
@@ -1,7 +1,6 @@
# Reusable workflow — called by project repos via `uses:` # Reusable workflow — called by project repos via `uses:`
# Requires Gitea 1.21+ for workflow_call support. # Shell-based — no node/JS actions required, works in host mode.
# Runner assumed on Pi 5 (ARM64 native) — no QEMU needed. # Requires: git and docker available on the runner host.
# If runner moves to x86 NAS, uncomment the QEMU setup steps.
name: Build and push Docker image name: Build and push Docker image
@@ -12,16 +11,15 @@ on:
description: "Image name (no registry prefix)" description: "Image name (no registry prefix)"
required: true required: true
type: string type: string
repo_name:
description: "Source repo name (e.g. mtg-meta-scraper)"
required: true
type: string
dockerfile_path: dockerfile_path:
description: "Path to Dockerfile" description: "Path to Dockerfile relative to repo root"
required: false required: false
type: string type: string
default: "Dockerfile" default: "Dockerfile"
platforms:
description: "Target platform(s)"
required: false
type: string
default: "linux/arm64"
registry: registry:
description: "Container registry host" description: "Container registry host"
required: false required: false
@@ -37,44 +35,36 @@ on:
required: true required: true
REGISTRY_TOKEN: REGISTRY_TOKEN:
required: true required: true
GITEA_TOKEN:
required: true
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 run: |
rm -rf /tmp/${{ inputs.image_name }}-build
git clone https://oauth2:${{ secrets.GITEA_TOKEN }}@${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.repo_name }}.git /tmp/${{ inputs.image_name }}-build
cd /tmp/${{ inputs.image_name }}-build && git checkout ${{ gitea.sha }}
# Uncomment if runner is on x86 NAS (cross-compiling for Pi ARM64): - name: Login to registry
# - name: Set up QEMU run: |
# uses: docker/setup-qemu-action@v3 echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ inputs.registry }} -u "${{ secrets.REGISTRY_USER }}" --password-stdin
# - 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 - name: Build and push
uses: docker/build-push-action@v5 run: |
with: SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
context: . IMAGE="${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }}"
file: ${{ inputs.dockerfile_path }} docker build /tmp/${{ inputs.image_name }}-build \
push: true -f /tmp/${{ inputs.image_name }}-build/${{ inputs.dockerfile_path }} \
tags: ${{ steps.meta.outputs.tags }} -t "${IMAGE}:latest" \
labels: ${{ steps.meta.outputs.labels }} -t "${IMAGE}:sha-${SHORT_SHA}"
platforms: ${{ inputs.platforms }} docker push "${IMAGE}:latest"
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }}:buildcache docker push "${IMAGE}:sha-${SHORT_SHA}"
cache-to: type=registry,ref=${{ inputs.registry }}/${{ inputs.registry_owner }}/${{ inputs.image_name }}:buildcache,mode=max
- name: Cleanup
if: always()
run: |
docker logout ${{ inputs.registry }} || true
rm -rf /tmp/${{ inputs.image_name }}-build