@@ -16,24 +16,34 @@ require_env INPUT_DOCKER_REGISTRY
1616require_env INPUT_DOCKER_IMAGE
1717
1818BUILD=" true"
19+ # ALIAS_TAG is an additional immutable tag pushed alongside TAG (see set_branch_tags).
20+ ALIAS_TAG=" "
1921
20- # branch_tag builds the immutable tag for an environment branch.
22+ # set_branch_tags computes the immutable tag(s) for an environment branch and
23+ # assigns them to the globals TAG and ALIAS_TAG.
2124#
22- # When INPUT_DOCKER_TAG_TIMESTAMP is "true" the tag gets a UTC timestamp inserted
23- # before the short SHA (e.g. dev-20260602143055-abcdef12). This makes branch tags
24- # sortable by Flux image automation (numerical policy) — the git SHA alone is not
25- # orderable, so Flux cannot otherwise tell which build is newest. The SHA is kept
26- # for traceability. When the flag is unset/false the legacy <prefix>-<sha> shape
27- # is produced, so existing consumers are unaffected.
25+ # When INPUT_DOCKER_TAG_TIMESTAMP is "true" the canonical TAG gets a UTC timestamp
26+ # inserted before the short SHA (e.g. dev-20260602143055-abcdef12). This makes
27+ # branch tags sortable by Flux image automation (numerical policy) — the git SHA
28+ # alone is not orderable, so Flux cannot otherwise tell which build is newest.
29+ # In that case ALIAS_TAG holds the legacy <prefix>-<short-sha> tag, which is also
30+ # pushed: it is the stable per-commit handle that retag-image.sh looks up to find
31+ # the source image for a release, so dropping it would break the release retag.
32+ # The alias does not match Flux's "<prefix>-<digits>-<hex>" pattern, so Flux
33+ # ignores it. When the flag is unset/false only the legacy <prefix>-<short-sha>
34+ # tag is produced, so existing consumers are unaffected.
2835#
2936# The timestamp is overridable via BUILD_TIMESTAMP for deterministic tests.
30- branch_tag () {
37+ set_branch_tags () {
3138 local prefix=" $1 "
39+ local sha=" ${GITHUB_SHA:: 8} "
3240 if [[ " ${INPUT_DOCKER_TAG_TIMESTAMP:- false} " == " true" ]]; then
3341 local ts=" ${BUILD_TIMESTAMP:- $(date -u +% Y% m% d% H% M% S)} "
34- echo " ${prefix} -${ts} -${GITHUB_SHA:: 8} "
42+ TAG=" ${prefix} -${ts} -${sha} "
43+ ALIAS_TAG=" ${prefix} -${sha} "
3544 else
36- echo " ${prefix} -${GITHUB_SHA:: 8} "
45+ TAG=" ${prefix} -${sha} "
46+ ALIAS_TAG=" "
3747 fi
3848}
3949
@@ -43,15 +53,15 @@ if [[ -n "${INPUT_DOCKER_CUSTOM_TAG:-}" ]]; then
4353 PUSH=" true"
4454 BUILD=" ${INPUT_DOCKER_DISABLE_RETAGGING:- false} "
4555elif [[ $GITHUB_REF == refs/heads/master ]]; then
46- TAG= " $( branch_tag master) "
56+ set_branch_tags master
4757 LATEST=" master"
4858 PUSH=" true"
4959elif [[ $GITHUB_REF == refs/heads/main ]]; then
50- TAG= " $( branch_tag main) "
60+ set_branch_tags main
5161 LATEST=" main"
5262 PUSH=" true"
5363elif [[ $GITHUB_REF == refs/heads/dev ]]; then
54- TAG= " $( branch_tag dev) "
64+ set_branch_tags dev
5565 LATEST=" dev"
5666 PUSH=" true"
5767elif [[ $GITHUB_REF == refs/tags/v* ]]; then
7181fi
7282
7383TAG_LIST=" ${INPUT_DOCKER_REGISTRY} /${INPUT_DOCKER_IMAGE} :${TAG} "
84+ if [[ -n " ${ALIAS_TAG:- } " ]]; then
85+ TAG_LIST+=" ,${INPUT_DOCKER_REGISTRY} /${INPUT_DOCKER_IMAGE} :${ALIAS_TAG} "
86+ fi
7487if [[ -n " ${LATEST:- } " ]]; then
7588 TAG_LIST+=" ,${INPUT_DOCKER_REGISTRY} /${INPUT_DOCKER_IMAGE} :${LATEST} "
7689fi
0 commit comments