Files
deac 2e9a99fe8f
/ publish (push) Successful in 7s
add tag prefix for docker images
2026-05-31 19:15:15 -04:00

69 lines
2.3 KiB
YAML

name: Docker Build and Push
description: Build a Docker image and push it to the Gitea container registry
inputs:
REGISTRY:
description: "Container registry hostname"
default: "gitea.pixelparasol.com"
REGISTRY_USERNAME:
description: "Registry login username"
default: "deac"
REGISTRY_TOKEN:
description: "Registry login token or password"
required: true
IMAGE_PATH:
description: "Full registry image path (e.g. gitea.pixelparasol.com/stat-tackler/stat-tackler-api)"
required: true
IMAGE_TAG:
description: "Tag to apply in addition to latest (e.g. stage-<sha>)"
required: true
PLATFORMS:
description: "Comma-separated buildx platform list"
default: "linux/amd64,linux/arm/v7,linux/arm64"
ARTIFACT_NAME:
description: "Name of the build artifact to download"
default: "dist"
ARTIFACT_PATH:
description: "Destination path for the downloaded artifact"
default: "dist"
TAG_LATEST:
description: "Also tag and push the image as latest"
default: "false"
TAG_PREFIX:
description: "Optional prefix to prepend to IMAGE_TAG (e.g. 'dev' produces 'dev-<tag>'). Does not affect the latest tag."
default: ""
WORKING_DIRECTORY:
description: "Working directory for the Docker build"
default: "."
runs:
using: composite
steps:
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.REGISTRY }}
username: ${{ inputs.REGISTRY_USERNAME }}
password: ${{ inputs.REGISTRY_TOKEN }}
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.ARTIFACT_NAME }}
path: ${{ inputs.ARTIFACT_PATH }}
- name: Docker Build and Push
shell: sh
run: |
TAG="${{ inputs.IMAGE_TAG }}"
if [ -n "${{ inputs.TAG_PREFIX }}" ]; then
TAG="${{ inputs.TAG_PREFIX }}-${TAG}"
fi
TAGS="-t ${{ inputs.IMAGE_PATH }}:${TAG}"
if [ "${{ inputs.TAG_LATEST }}" = "true" ]; then
TAGS="$TAGS -t ${{ inputs.IMAGE_PATH }}:latest"
fi
docker buildx build -f ${{ inputs.WORKING_DIRECTORY }}/Dockerfile ${{ inputs.WORKING_DIRECTORY }} \
--platform ${{ inputs.PLATFORMS }} \
--push \
$TAGS