From 513c7862a21613943c3591bba4d05e816c79bab4 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Thu, 2 Jul 2020 14:23:36 -0500
Subject: [PATCH] Add docker tag to CI jobs

---
 .gitlab-ci.yml | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fb65b24..d667ca8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,6 +16,8 @@ variables:
 build ci:
   stage: .pre
   image: docker:19.03.1
+  tags:
+    - docker
   services:
     - docker:19.03.1-dind
   before_script:
@@ -61,6 +63,12 @@ build ci:
       sed -i "s/^appVersion: .*\$/appVersion: ${docker_tag}/g" ${SUBCOMP_CHART_DIR}/Chart.yaml
     # debug:
     - helm template ${SUBCOMP_CHART_DIR} .
+  artifacts:
+    paths:
+      - chart/${SUBCOMP_CHART_DIR}
+    variables:
+      - docker_tag
+    expire_in: 6 hours
 # XXX: Do we always want to clone the subcomponent
 #  rules:
 #    - if: '$GEOSPHERE_SUBCOMP == ""'
@@ -73,4 +81,31 @@ get_chart_grb:
   extends: .get_chart_tmpl
   variables:
     SUBCOMP_REPOS: "geosphere-grb"
-    SUBCOMP_CHART_DIR: "cspp-geo-grb"
\ No newline at end of file
+    SUBCOMP_CHART_DIR: "cspp-geo-grb"
+
+# TODO: Use "environment: " to define a job for production and one for development
+#       https://docs.gitlab.com/ee/ci/yaml/#environment
+deploy_grb:
+  stage: deploy_grb
+  tags:
+    - docker
+  script:
+    - if [ -n "$CI_COMMIT_TAG" ]; then
+        ns="geosphere";
+      else
+        ns="geosphere-test";
+      fi
+    - echo $ns
+    - cd chart
+    # copy secret kubeconfig to the mounted (pwd) directory
+    - cp $kubekorner_k3s_config .
+    - kubeconfig=$(basename $kubekorner_k3s_config)
+    # namespace names are the same as domain names
+#    - helm upgrade -v 2 --install --kubeconfig $kubeconfig --namespace $ns --set grbNotifier.image.dockerTag=$docker_tag --set grbProcessor.env[0].name=APID_FILTER --set grbProcessor.env[0].value="GOES-16-ABI-Only.xml" cspp-geo-grb cspp-geo-grb/
+  needs:
+    - job: get_chart_grb
+      artifacts: true
+  rules:
+    - if: '$kubekorner_k3s_config == ""'
+      when: never
+    - when: on_success
-- 
GitLab