Skip to content
Snippets Groups Projects
generate-deploy-stages.sh 1.05 KiB
Newer Older
#!/bin/bash

basedir=$( cd "$(dirname "$0")" ; pwd -P )
echo TRIGGER_PAYLOAD=$TRIGGER_PAYLOAD
cat $TRIGGER_PAYLOAD
cat $TRIGGER_PAYLOAD | python3 -c "import sys, json; print(json.loads(json.load(sys.stdin)['payload'])['ref'])" | grep "uat"
TAG=$(cat ${TRIGGER_PAYLOAD} | python3 -c "import sys, json; print(json.loads(json.load(sys.stdin)['payload'])['ref'])" | grep "uat")
touch deploy.yml
if [ ! -z "${TAG}" ]; then
  git clone --single-branch --branch ${TAG} https://github.com/MAAP-Project/maap-workspaces.git
  pushd maap-workspaces
  ls -d base_images/*/* > ${basedir}/images.txt
  cat ${basedir}/images.txt
  template="${basedir}/deploy.yml.tmpl"
  cat ${basedir}/images.txt | while read image
  do
    if [[ "$image" == base_images/*/* ]]; then
      second_dir=$(echo "$image" | cut -d'/' -f2)
      export BASE_IMAGE_TYPE=${second_dir}
      export TAG=${TAG}
      export DIT_REGISTRY=${DIT_REGISTRY}
      cat ${template} | CI_JOB_TOKEN='$CI_JOB_TOKEN' envsubst >> deploy.yml
echo "Generate stages.yaml"
cat deploy.yml || true