From de9fa950dd127be5c889de7f032a27d12172b796 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: Tue, 17 Sep 2024 20:49:32 +0000 Subject: [PATCH] Add template to deploy custom images --- deploy_custom_images.yml.tmpl | 9 +++++++++ generate-deploy-stages.sh | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 deploy_custom_images.yml.tmpl diff --git a/deploy_custom_images.yml.tmpl b/deploy_custom_images.yml.tmpl new file mode 100644 index 0000000..fb85508 --- /dev/null +++ b/deploy_custom_images.yml.tmpl @@ -0,0 +1,9 @@ +${CUSTOM_IMAGE_TYPE}: + script: + - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY + - docker pull $DIT_REGISTRY/custom_images/${CUSTOM_IMAGE_TYPE}:main + - docker tag $DIT_REGISTRY/custom_images/${CUSTOM_IMAGE_TYPE}:main $CI_REGISTRY/root/maap-workspaces/custom_images/${CUSTOM_IMAGE_TYPE}:${TAG} + - docker push $CI_REGISTRY/root/maap-workspaces/custom_images/${CUSTOM_IMAGE_TYPE}:${TAG} + + tags: + - shell diff --git a/generate-deploy-stages.sh b/generate-deploy-stages.sh index bde1925..c417639 100644 --- a/generate-deploy-stages.sh +++ b/generate-deploy-stages.sh @@ -11,17 +11,26 @@ 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 + ls -d custom_images/*/* > ${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 done fi -- GitLab