From 5ab8b3f7c1d21fb334b49e058f8cbe2010a47f5c Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Thu, 13 Aug 2020 21:22:18 -0500
Subject: [PATCH] Fix pvc creation when using git tag builds

---
 ci_geosphere/gitlab-ci.yaml | 6 ++----
 helpers/create_pvc.sh       | 7 ++++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/ci_geosphere/gitlab-ci.yaml b/ci_geosphere/gitlab-ci.yaml
index 866ecd8..9a7738c 100644
--- a/ci_geosphere/gitlab-ci.yaml
+++ b/ci_geosphere/gitlab-ci.yaml
@@ -11,8 +11,6 @@ gs create geotiff storage:
   extends: .helm_based_job
   stage: create storage
   script:
-    - echo "$CI_COMMIT_BRANCH"
-    - echo "$CI_COMMIT_TAG"
     - ns=$(./helpers/get_namespace.sh)
     # copy secret kubeconfig to the mounted (pwd) directory
     - cp $kubekorner_k3s_config .
@@ -25,6 +23,7 @@ gs create geotiff storage:
       when: never
     - if: '$kubekorner_k3s_config == null'
       when: never
+    # this will always be true for tags
     - changes:
         - ci_geosphere/geotiff-pvc.yaml
     - if: $CREATE_STORAGE
@@ -33,8 +32,6 @@ gs create shapefile storage:
   extends: .helm_based_job
   stage: create storage
   script:
-    - echo "$CI_COMMIT_BRANCH"
-    - echo "$CI_COMMIT_TAG"
     - ns=$(./helpers/get_namespace.sh)
     # copy secret kubeconfig to the mounted (pwd) directory
     - cp $kubekorner_k3s_config .
@@ -47,6 +44,7 @@ gs create shapefile storage:
       when: never
     - if: '$kubekorner_k3s_config == null'
       when: never
+    # this will always be true for tags
     - changes:
         - ci_geosphere/shapefiles-pvc.yaml
     - if: $CREATE_STORAGE
diff --git a/helpers/create_pvc.sh b/helpers/create_pvc.sh
index 99051e6..b24e690 100755
--- a/helpers/create_pvc.sh
+++ b/helpers/create_pvc.sh
@@ -22,10 +22,11 @@ else
 fi
 
 
-# If another project started this build then we know the provided definition
-# didn't change. Let's make sure it exists on the cluster and if so, don't
+# If another project started this build or we don't know if the file changed
+# (git tag) then we know the provided definition didn't change (or probably
+# didn't). Let's make sure it exists on the cluster and if so, don't
 # try to recreate it.
-if [[ $CI_PIPELINE_SOURCE == "pipeline" ]]; then
+if [[ $CI_PIPELINE_SOURCE == "pipeline" ]] || [[ $CI_COMMIT_TAG != null ]]; then
     pvc_exists=$(kubectl $EXTRA_ARGS get pvc $pvc_name -o jsonpath="{.metadata.name}" || echo "")
     if [[ "$pvc_exists" != "" ]]; then
         # it exists
-- 
GitLab