From d949e79f2e915b53bc58a20885d34ce04b16345a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: Fri, 12 May 2023 03:30:31 +0000
Subject: [PATCH] Update generate-deploy-stages.sh

---
 generate-deploy-stages.sh | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/generate-deploy-stages.sh b/generate-deploy-stages.sh
index 4c6b9a1..df90721 100644
--- a/generate-deploy-stages.sh
+++ b/generate-deploy-stages.sh
@@ -2,18 +2,23 @@
 
 set -e
 basedir=$( cd "$(dirname "$0")" ; pwd -P )
-cat $TRIGGER_PAYLOAD | python3 -c "import sys, json; print(json.loads(json.load(sys.stdin)['payload'])['ref'])" | grep "-uat"
+cat $TRIGGER_PAYLOAD 
+cat $TRIGGER_PAYLOAD | python3 -c "import sys, json; print(json.loads(json.load(sys.stdin)['payload'])['ref'])" | grep "uat"
 TAG=$(!!)
-git clone --single-branch --branch ${TAG} https://github.com/MAAP-Project/maap-workspaces.git
-pushd maap-workspaces
-find base_images -type d -depth 1 > ${basedir}/images.txt
-cat ${basedir}/images.txt
-template="${basedir}/deploy.yml.tmpl"
-cat ${basedir}/images.txt | while read image
-do
-  export BASE_IMAGE_TYPE=$(basename ${image})
-  export TAG=${TAG}
-  cat ${template} | CI_JOB_TOKEN='$CI_JOB_TOKEN' CI_REGISTRY='$CI_REGISTRY' envsubst >> deploy.yml
-done
+touch deploy.yml
+if [ -z "${TAG}" ]; then
+  git clone --single-branch --branch ${TAG} https://github.com/MAAP-Project/maap-workspaces.git
+  pushd maap-workspaces
+  find base_images -type d -depth 1 > ${basedir}/images.txt
+  cat ${basedir}/images.txt
+  template="${basedir}/deploy.yml.tmpl"
+  cat ${basedir}/images.txt | while read image
+  do
+    export BASE_IMAGE_TYPE=$(basename ${image})
+    export TAG=${TAG}
+    cat ${template} | CI_JOB_TOKEN='$CI_JOB_TOKEN' CI_REGISTRY='$CI_REGISTRY' envsubst >> deploy.yml
+  done
+fi
+
 echo "Generate stages.yaml"
 cat deploy.yml || true
-- 
GitLab