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:
1 file changed
+29
-6
@@ -7,6 +7,13 @@ on:
|
||||
# ...); only the app package's tag corresponds to this image.
|
||||
- "irtt-rs/v*"
|
||||
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:
|
||||
IMAGE_NAME: irtt-server
|
||||
@@ -22,19 +29,35 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||
|
||||
- name: Determine image tags
|
||||
id: meta
|
||||
run: |
|
||||
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
|
||||
version="${GITHUB_REF_NAME#irtt-rs/v}"
|
||||
backfill_tag="${{ github.event.inputs.tag }}"
|
||||
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"
|
||||
if [ "${push_latest}" = true ]; then
|
||||
echo "tags=${version},latest" >> "$GITHUB_OUTPUT"
|
||||
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"
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user