Skip to content

Commit

Permalink
Use "production" floating tag when uilding docker image from version …
Browse files Browse the repository at this point in the history
…git tags (#1272)

* use "production" floating tag when uilding docker image from version git tags

* tiny fix
  • Loading branch information
svyatonik authored Dec 24, 2021
1 parent ded9ff6 commit 38c6c3a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ default:
when:
- runner_system_failure
- unknown_failure
- api_failure
- api_failure
interruptible: true
tags:
- linux-docker
Expand Down Expand Up @@ -240,7 +240,14 @@ build-nightly:
elif [[ "${CI_COMMIT_REF_NAME}" ]]; then
VERSION=$(echo ${CI_COMMIT_REF_NAME} | sed -r 's#/+#-#g');
fi
- echo "Effective tags = ${VERSION} sha-${CI_COMMIT_SHORT_SHA} latest"
# When building from version tags (v1.0, v2.1rc1, ...) we'll use "production" to tag
# docker image. In all other cases, it'll be "latest".
- if [[ $CI_COMMIT_REF_NAME =~ ^v[0-9]+\.[0-9]+.*$ ]]; then
FLOATING_TAG="production";
else
FLOATING_TAG="latest";
fi
- echo "Effective tags = ${VERSION} sha-${CI_COMMIT_SHORT_SHA} ${FLOATING_TAG}"
secrets:
DOCKER_HUB_USER:
vault: cicd/gitlab/parity/DOCKER_HUB_USER@kv
Expand All @@ -260,15 +267,15 @@ build-nightly:
--build-arg VERSION="${VERSION}"
--tag "${IMAGE_NAME}:${VERSION}"
--tag "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
--tag "${IMAGE_NAME}:latest"
--tag "${IMAGE_NAME}:${FLOATING_TAG}"
--file "${DOCKERFILE}" .
# The job will success only on the protected branch
- echo "${DOCKER_HUB_PASS}" |
buildah login --username "${DOCKER_HUB_USER}" --password-stdin docker.io
- buildah info
- buildah push --format=v2s2 "${IMAGE_NAME}:${VERSION}"
- buildah push --format=v2s2 "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
- buildah push --format=v2s2 "${IMAGE_NAME}:latest"
- buildah push --format=v2s2 "${IMAGE_NAME}:${FLOATING_TAG}"
after_script:
- env REGISTRY_AUTH_FILE= buildah logout --all

Expand Down

0 comments on commit 38c6c3a

Please sign in to comment.