Skip to content
Snippets Groups Projects
generate-deploy-ops-stages.sh 1.27 KiB
Newer Older
basedir=$( cd "$(dirname "$0")" ; pwd -P )
touch deploy.yml
echo "Running CI for ${TAG}"
if [[ ! -z "${TAG}" ]]; then
  git clone --single-branch --branch ${TAG} https://github.com/MAAP-Project/maap-workspaces.git
  pushd maap-workspaces
  # List paths containing dockerfiles
  find base_images -name "Dockerfile" -type f > ${basedir}/images.txt
  find custom_images -name "Dockerfile" -type f >> ${basedir}/images.txt
  popd
  cat ${basedir}/images.txt
  template="${basedir}/deploy.yml.tmpl"
  cat ${basedir}/images.txt | while read image
  do
    if [[ "$image" == base_images/*/* ]]; then
      template="${basedir}/deploy.yml.tmpl"
      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
    elif [[ "$image" == custom_images/*/* ]]; then
      template="${basedir}/deploy_custom_images.yml.tmpl"
      second_dir=$(echo "$image" | cut -d'/' -f2)
      export CUSTOM_IMAGE_TYPE=${second_dir}
      export TAG=${TAG}
      export DIT_REGISTRY=${DIT_REGISTRY}
      cat ${template} | CI_JOB_TOKEN='$CI_JOB_TOKEN' envsubst >> deploy.yml
    fi
fi

echo "Generate stages.yaml"
cat deploy.yml || true