From 8e1699d86f7fe88da4a48a986c61e2a430536c65 Mon Sep 17 00:00:00 2001
From: Jakob Moser <moser@cl.uni-heidelberg.de>
Date: Thu, 26 Sep 2024 20:45:23 +0200
Subject: [PATCH] Move building Docker image to deployment stage

Because building it actually means also publishing it, so we only want that when the tests succeed.
---
 .gitlab-ci.yml | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3607cff..1674c4c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,23 +1,3 @@
-# This snippet is copied and modified from the GitLab Documentation (as of 2021-01-10, the contents of the script seem to have changed by now)
-#   * Title of the documentation page: "Building a Docker image with kaniko"
-#   * Author: (c) 2011-present GitLab B.V.
-#   * URL: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html#building-a-docker-image-with-kaniko
-#   * License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)
-build-docker:
-    image:
-        name: gcr.io/kaniko-project/executor:debug
-        entrypoint: [""]
-    stage: build
-    before_script:
-        - mkdir -p /kaniko/.docker
-        - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
-    script:
-        - echo "{\"commit\":\"$CI_COMMIT_SHA\",\"datetime\":\"$CI_COMMIT_TIMESTAMP\"}" > PORTAL_VERSION
-        - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
-    only:
-        - master
-# End of adapted snippet
-
 lint-openapi:
     image:
         name: redocly/cli
@@ -54,3 +34,23 @@ test-frontend:
             - cypress/videos
             - cypress/screenshots
         expire_in: 1 week
+
+# This snippet is copied and modified from the GitLab Documentation (as of 2021-01-10, the contents of the script seem to have changed by now)
+#   * Title of the documentation page: "Building a Docker image with kaniko"
+#   * Author: (c) 2011-present GitLab B.V.
+#   * URL: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html#building-a-docker-image-with-kaniko
+#   * License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)
+build-docker:
+    image:
+        name: gcr.io/kaniko-project/executor:debug
+        entrypoint: [""]
+    stage: deploy
+    before_script:
+        - mkdir -p /kaniko/.docker
+        - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
+    script:
+        - echo "{\"commit\":\"$CI_COMMIT_SHA\",\"datetime\":\"$CI_COMMIT_TIMESTAMP\"}" > PORTAL_VERSION
+        - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
+    only:
+        - master
+# End of adapted snippet
-- 
GitLab