Skip to content

Create build-platform.yml #1

Create build-platform.yml

Create build-platform.yml #1

name: Build Platform Image
on:
workflow_call:
inputs:
platform:
required: true
type: string
description: 'Platform to build (linux/amd64 or linux/arm64)'
image_name:
required: true
type: string
description: 'Image name'
version:
required: true
type: string
description: 'Version tag'
secrets:
GITHUB_TOKEN:

Check failure on line 19 in .github/workflows/build-platform.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-platform.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU (for ARM builds)
if: inputs.platform == 'linux/arm64'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set platform suffix
id: platform
run: |
PLATFORM_SUFFIX=$(echo "${{ inputs.platform }}" | sed 's|linux/||')
echo "suffix=$PLATFORM_SUFFIX" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ inputs.platform }}
push: true
tags: ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.version }}-${{ steps.platform.outputs.suffix }}
cache-from: type=gha,scope=${{ steps.platform.outputs.suffix }}
cache-to: type=gha,mode=max,scope=${{ steps.platform.outputs.suffix }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ inputs.version }}
- name: Build complete
run: |
echo "✅ Built ${{ inputs.platform }} image: ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.version }}-${{ steps.platform.outputs.suffix }}"