project-nomad/.github/workflows/build-primary-image.yml
Workflow config file is invalid. Please check your config file: yaml: unmarshal errors: line 54: mapping key "uses" already defined at line 52
2026-03-25 18:32:13 -04:00

99 lines
3.0 KiB
YAML

name: Build Primary Docker Image
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version to label the Docker image under (no "v" prefix, e.g. "1.2.3")'
required: true
type: string
tag_latest:
description: 'Also tag this image as :latest? (Keep false for RC and beta releases)'
required: false
type: boolean
default: false
env:
IMAGE: ghcr.io/crosstalk-solutions/project-nomad
jobs:
check_authorization:
name: Check authorization to publish new Docker image
runs-on: ubuntu-latest
outputs:
isAuthorized: ${{ steps.check-auth.outputs.is_authorized }}
steps:
- name: check-auth
id: check-auth
run: echo "is_authorized=${{ contains(secrets.DEPLOYMENT_AUTHORIZED_USERS, github.triggering_actor) }}" >> $GITHUB_OUTPUT
build:
name: Build Docker image (${{ matrix.platform }})
needs: check_authorization
if: needs.check_authorization.outputs.isAuthorized == 'true'
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-24.04
suffix: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
suffix: arm64
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: actions/checkout@v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
platforms: ${{ matrix.platform }}
tags: ${{ env.IMAGE }}:${{ inputs.version }}-${{ matrix.suffix }}
build-args: |
VERSION=${{ inputs.version }}
BUILD_DATE=${{ github.event.workflow_run.created_at }}
VCS_REF=${{ github.sha }}
manifest:
name: Create multi-arch manifest
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest
run: |
TAGS="${{ env.IMAGE }}:${{ inputs.version }} ${{ env.IMAGE }}:v${{ inputs.version }}"
if [ "${{ inputs.tag_latest }}" = "true" ]; then
TAGS="$TAGS ${{ env.IMAGE }}:latest"
fi
for TAG in $TAGS; do
docker manifest create "$TAG" \
"${{ env.IMAGE }}:${{ inputs.version }}-amd64" \
"${{ env.IMAGE }}:${{ inputs.version }}-arm64"
docker manifest push "$TAG"
done