From 2d6e2cfe5ea896f72e9a25f3d8b9c7e4cc6b3654 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 13 Apr 2024 09:57:28 +0000 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 174952c..824faa0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,28 +26,32 @@ build: only: - merge_requests - pushes + - web docker: stage: docker + dependencies: + - build image: name: gcr.io/kaniko-project/executor:v1.14.0-debug entrypoint: [""] script: - tar -xzvf build-artifacts.tar.gz - - echo $DOCKERHUB_TOKEN | docker login --username $DOCKERHUB_USERNAME --password-stdin + - | + # If pipeline runs on the default branch: Set tag to "latest" + if test "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH"; then + tag="latest" + # If pipeline is a tag pipeline, set tag to the git commit tag + elif test -n "$CI_COMMIT_TAG"; then + tag="$CI_COMMIT_TAG" + # Else set the tag to the git commit sha + else + tag="$CI_COMMIT_SHA" + fi + - | - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" - --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" - - /kaniko/executor - --context "${CI_PROJECT_DIR}" - --dockerfile "${CI_PROJECT_DIR}/Dockerfile" - --destination "zyner/xyter:${CI_COMMIT_TAG}" - # Tag name - - docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} $CI_REGISTRY_IMAGE:latest - - docker tag zyner/xyter:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE:latest - # Latest - - docker push zyner/xyter:latest - - docker push $CI_REGISTRY_IMAGE:latest + --destination "${CI_REGISTRY_IMAGE}:${tag}" # only: # - tags