From 9998c489576a87baf2e92688a4ad783a3dffbbf1 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 11 Dec 2020 21:23:35 +0200
Subject: [PATCH] Refactor .gitlab-ci.yml.

Can't use the "host" variable as the tag. Workaround that with YAML
anchors (ugly but works).
---
 .gitlab-ci.yml | 67 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4b0f140..4ceaa6c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,35 +20,41 @@ pre-commit:
     paths:
       - .cache/
 
-build:
+build-host01:
   stage: build
   tags:
-    - "$host"
-  variables:
+    - host01.shore.co.il
+  variables: &build_vars
     COMPOSE_DOCKER_CLI_BUILD: "1"
     DOCKER_BUILDKIT: "1"
-  script:
+  script: &build_script
     - docker-compose build --no-cache --pull
     - docker-compose pull --quiet
-  parallel: &parallel
-    matrix:
-      - host:
-          - host01.shore.co.il
-          - kodi.shore.co.il
-        REGISTER_RUN_UNTAGGED: "false"
-      - host:
-          - ns4.shore.co.il
-        REGISTER_RUN_UNTAGGED: "true"
-
-run:
+
+build-kodi:
+  stage: build
+  tags:
+    - kodi.shore.co.il
+  variables: *build_vars
+  script: *build_script
+
+build-ns4:
+  stage: build
+  tags:
+    - ns4.shore.co.il
+  variables: *build_vars
+  script: *build_script
+
+run-host01:
   stage: run
   tags:
-    - $host
+    - host01.shore.co.il
   variables:
-    RUNNER_NAME: "$host"
-    RUNNER_TAG_LIST: "$host"
+    RUNNER_NAME: host01.shore.co.il
+    RUNNER_TAG_LIST: host01.shore.co.il
+    REGISTER_RUN_UNTAGGED: "false"
   when: manual
-  script:
+  script: &run-script
     - docker-compose up --detach --remove-orphans
     # yamllint disable rule:line-length
     - |
@@ -58,4 +64,25 @@ run:
             sleep 10
         done
         ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$'
-  parallel: *parallel
+
+run-kodi:
+  stage: run
+  tags:
+    - kodi.shore.co.il
+  variables:
+    RUNNER_NAME: kodi.shore.co.il
+    RUNNER_TAG_LIST: kodi.shore.co.il
+    REGISTER_RUN_UNTAGGED: "false"
+  when: manual
+  script: *run-script
+
+run-ns4:
+  stage: run
+  tags:
+    - ns4.shore.co.il
+  variables:
+    RUNNER_NAME: ns4.shore.co.il
+    RUNNER_TAG_LIST: ns4.shore.co.il
+    REGISTER_RUN_UNTAGGED: "true"
+  when: manual
+  script: *run-script
-- 
GitLab