From 2fb124e50549a097e433b7bce6a8fe4a772f0d62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de>
Date: Tue, 2 Mar 2021 17:51:32 +0100
Subject: [PATCH] Add publish step for random scheduler

---
 .gitlab-ci.yml                                | 27 +++++++++++++++++++
 .../infrastructure/random-scheduler/README.md |  2 +-
 .../random-scheduler/deployment.yaml          |  2 +-
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 22758f39b..bb4a26e2b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -198,3 +198,30 @@ deploy-theodolite:
     - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
       when: manual
       allow_failure: true
+
+
+# Theodolite Random Scheduler
+
+deploy-random-scheduler:
+  stage: deploy
+  extends:
+    - .dind
+  script:
+    - DOCKER_TAG_NAME=$(echo $CI_COMMIT_REF_SLUG- | sed 's/^master-$//')
+    - docker build --pull -t theodolite-random-scheduler` execution/infrastructure/random-scheduler
+    - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite-random-scheduler` $CR_HOST/$CR_ORG/theodolite-random-scheduler`:${DOCKER_TAG_NAME}latest"
+    - "[ $CI_COMMIT_TAG ] && docker tag theodolite-random-scheduler` $CR_HOST/$CR_ORG/theodolite-random-scheduler`:$CI_COMMIT_TAG"
+    - echo $CR_PW | docker login $CR_HOST -u $CR_USER --password-stdin
+    - docker push $CR_HOST/$CR_ORG/theodolite-random-scheduler`
+    - docker logout
+  rules:
+    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $CI_COMMIT_TAG"
+      when: always
+    - changes:
+      - execution/infrastructure/random-scheduler/**/*
+      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
+      when: always
+    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
+      when: manual
+      allow_failure: true
+      
\ No newline at end of file
diff --git a/execution/infrastructure/random-scheduler/README.md b/execution/infrastructure/random-scheduler/README.md
index 2d8da30a3..59b9acb0a 100644
--- a/execution/infrastructure/random-scheduler/README.md
+++ b/execution/infrastructure/random-scheduler/README.md
@@ -9,4 +9,4 @@ Run the following commands
 - `docker push <user>/theodolite-random-scheduler`
 
 ## Deployment
-Deploy the `deployment.yaml` file into Kubernetes. Note, that the `TARGET_NAMESPACE` environment variable specifies the operating namespace of the random scheduler.
\ No newline at end of file
+Deploy the `deployment.yaml` file into Kubernetes. Note, that the `TARGET_NAMESPACE` environment variable specifies the operating namespace of the random scheduler.
diff --git a/execution/infrastructure/random-scheduler/deployment.yaml b/execution/infrastructure/random-scheduler/deployment.yaml
index 84e2c2593..3c8c0ed5a 100644
--- a/execution/infrastructure/random-scheduler/deployment.yaml
+++ b/execution/infrastructure/random-scheduler/deployment.yaml
@@ -18,7 +18,7 @@ spec:
       serviceAccount: random-scheduler
       containers:
         - name: random-scheduler
-          image: theodolite/random-scheduler:latest
+          image: ghcr.io/cau-se/theodolite-random-scheduler:latest
           imagePullPolicy: Always
           env:
             - name: TARGET_NAMESPACE
-- 
GitLab