Skip to content

PilotSwarm 0.5.22

PilotSwarm 0.5.22 #61

name: Publish Starter Docker Image
on:
workflow_dispatch:
inputs:
push:
description: Push image to Docker Hub
required: true
default: false
type: boolean
image_tag:
description: Optional extra tag, for example test or rc1
required: false
default: ""
release_tag:
description: Optional release tag to publish, for example v0.1.25. Also publishes the bare version tag.
required: false
default: ""
publish_latest:
description: Also publish latest when release_tag is provided
required: false
default: true
type: boolean
platforms:
description: Build platforms for the starter image.
required: false
default: linux/amd64,linux/arm64
release:
types: [published]
permissions:
contents: read
env:
IMAGE_NAME: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/pilotswarm-starter
jobs:
build-and-publish:
name: Build starter image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- 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 Docker Hub
if: github.event_name == 'release' || inputs.push
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Compute tags
id: tags
env:
EXTRA_TAG: ${{ inputs.image_tag }}
RELEASE_TAG_INPUT: ${{ inputs.release_tag }}
PUBLISH_LATEST: ${{ inputs.publish_latest }}
shell: bash
run: |
set -euo pipefail
tags=()
add_tag() {
local tag="$1"
for existing in "${tags[@]}"; do
if [[ "${existing}" == "${tag}" ]]; then
return
fi
done
tags+=("${tag}")
}
add_tag "${IMAGE_NAME}:sha-${GITHUB_SHA::12}"
release_tag=""
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
release_tag="${GITHUB_REF_NAME}"
elif [[ -n "${RELEASE_TAG_INPUT}" ]]; then
release_tag="${RELEASE_TAG_INPUT}"
fi
if [[ -n "${release_tag}" ]]; then
version_tag="${release_tag#v}"
add_tag "${IMAGE_NAME}:${release_tag}"
if [[ "${version_tag}" != "${release_tag}" ]]; then
add_tag "${IMAGE_NAME}:${version_tag}"
fi
if [[ "${GITHUB_EVENT_NAME}" == "release" || "${PUBLISH_LATEST}" == "true" ]]; then
add_tag "${IMAGE_NAME}:latest"
fi
fi
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && -n "${EXTRA_TAG}" ]]; then
add_tag "${IMAGE_NAME}:${EXTRA_TAG}"
fi
{
echo "tags<<EOF"
printf '%s\n' "${tags[@]}"
echo "EOF"
} >> "${GITHUB_OUTPUT}"
- name: Build and optionally push starter image
uses: docker/build-push-action@v6
with:
context: .
file: deploy/Dockerfile.starter
platforms: ${{ inputs.platforms || 'linux/amd64,linux/arm64' }}
push: ${{ github.event_name == 'release' || inputs.push }}
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max