Fix image tagging (again)

This CI environment is using a busybox `sh` so doesn't support all the
advanced features of bash.  Reimplement IMAGE_TAG processing so it
functions as intended.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
This commit is contained in:
Chris Evich
2022-11-16 10:53:52 -05:00
parent e214a0549c
commit b4dd3c667c

View File

@@ -22,9 +22,13 @@ build:
printenv | egrep '^CI_' | sort
# N/B: There could be more than one merge-request open with this branch's HEAD
- |
IMAGE_TAG="${CI_COMMIT_TAG:+${CI_COMMIT_TAG}}${CI_COMMIT_BRANCH:+${CI_COMMIT_BRANCH/main/latest}}";
if [[ -n "$CI_OPEN_MERGE_REQUESTS" ]]; then
IMAGE_TAG="${CI_COMMIT_BRANCH}";
if [[ -n "$CI_COMMIT_TAG" ]]; then
IMAGE_TAG="${CI_COMMIT_TAG}";
elif [[ -n "$CI_OPEN_MERGE_REQUESTS" ]]; then
IMAGE_TAG=mr$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d, -f -1 | cut -d\! -f 2);
elif [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
IMAGE_TAG="latest";
fi
echo "Building/Pushing to: ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}";
- |