Files
cronmaster/.github/workflows/docker-build.yml
2025-11-05 18:10:35 +00:00

52 lines
1.6 KiB
YAML

name: Reusable Docker Build Logic
on:
workflow_call:
inputs:
platform: { required: true, type: string }
suffix: { required: true, type: string }
runner: { required: true, type: string }
secrets:
token: { required: true }
jobs:
build:
runs-on: ${{ inputs.runner }}
permissions: { contents: read, packages: write }
steps:
- { name: Checkout repository, uses: actions/checkout@v4 }
- name: "Prepare repository name in lowercase"
id: repo
run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- { 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 the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.token }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.repo.outputs.name }}
tags: |
type=ref,event=branch,suffix=${{ inputs.suffix }}
type=ref,event=tag,suffix=${{ inputs.suffix }}
type=raw,value=latest,suffix=${{ inputs.suffix }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ inputs.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max