ci: support manual backfilling of past releases in Docker workflow

Add a tag input to manual triggers to allow building and publishing specific past versions without clobbering the "latest" image tag.
This commit is contained in:
Nils Andreas Svee committed 2026-08-26 16:54:40 +07:00
1 parent e2b70ac50a
commit fa055c0886
1 file changed
+29 -6
+29 -6
View File
@@ -7,6 +7,13 @@ on:
# ...); only the app package's tag corresponds to this image. # ...); only the app package's tag corresponds to this image.
- "irtt-rs/v*" - "irtt-rs/v*"
workflow_dispatch: workflow_dispatch:
inputs:
tag:
description: >-
Existing irtt-rs/vX.Y.Z tag to build and publish (backfill a past
release). Leave empty to build the ref this run was dispatched from.
required: false
type: string
env: env:
IMAGE_NAME: irtt-server IMAGE_NAME: irtt-server
@@ -22,19 +29,35 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Determine image tags - name: Determine image tags
id: meta id: meta
run: | run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then backfill_tag="${{ github.event.inputs.tag }}"
version="${GITHUB_REF_NAME#irtt-rs/v}" if [ -n "${backfill_tag}" ]; then
ref_name="${backfill_tag}"
# Backfilling a past release must never move "latest" onto an
# older build just because it's being published after the fact.
push_latest=false
else
ref_name="${GITHUB_REF_NAME}"
push_latest=true
fi
if [[ "${ref_name}" == irtt-rs/v* ]]; then
version="${ref_name#irtt-rs/v}"
else
# Manual dispatch off a branch, no tag given: tag by commit only.
version="sha-$(git rev-parse --short HEAD)"
push_latest=false
fi
echo "version=${version}" >> "$GITHUB_OUTPUT" echo "version=${version}" >> "$GITHUB_OUTPUT"
if [ "${push_latest}" = true ]; then
echo "tags=${version},latest" >> "$GITHUB_OUTPUT" echo "tags=${version},latest" >> "$GITHUB_OUTPUT"
else else
# Manual dispatch off a branch: tag by commit only, never touch
# "latest", so an ad-hoc build can't clobber the last release.
version="sha-$(git rev-parse --short HEAD)"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "tags=${version}" >> "$GITHUB_OUTPUT" echo "tags=${version}" >> "$GITHUB_OUTPUT"
fi fi