diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7b08003dbf113c2261f9cdeb839a6e93977d726..c1b3987aa5103e59170d3e56181e86269052b675 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -320,6 +320,25 @@ install-k8s: - .general_rules interruptible: true +# Terminates a droplet and deletes the branch container image once the MR for it is merged +terminate-droplet: + # Stage has to be the same as the step that created the VPS + # https://docs.gitlab.com/ee/ci/environments.html#automatically-stopping-an-environment + stage: install-cluster + # Gets triggered by on_stop of create-vps job + when: manual + variables: + GIT_STRATEGY: none + script: + - *debug_information + # Delete droplet + - python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${CI_COMMIT_REF_SLUG}\")" + # Delete container image if one was created + - "if [ \"$CI_CONTAINER_TAG\" != \"main\" ]; then curl --request DELETE --header \"PRIVATE-TOKEN: ${CLEANER_TOKEN}\" https://open.greenhost.net/api/v4/projects/stackspin%2Fstackspin/registry/repositories/73/tags/${CI_CONTAINER_TAG}; fi" + environment: + name: $CI_COMMIT_REF_SLUG + action: stop + # Stage: install-stackspin # ======================== # @@ -760,27 +779,3 @@ zulip-taiko: extends: - .taiko - .zulip_rules - - -# Etc -# === - - -# Terminates a droplet and deletes the branch container image once the MR for it is merged -terminate-droplet: - # Stage has to be the same as the step that created the VPS - # https://docs.gitlab.com/ee/ci/environments.html#automatically-stopping-an-environment - stage: create-vps - # Gets triggered by on_stop of create-vps job - when: manual - variables: - GIT_STRATEGY: none - script: - - *debug_information - # Delete droplet - - python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${CI_COMMIT_REF_SLUG}\")" - # Delete container image if one was created - - "if [ \"$CI_CONTAINER_TAG\" != \"main\" ]; then curl --request DELETE --header \"PRIVATE-TOKEN: ${CLEANER_TOKEN}\" https://open.greenhost.net/api/v4/projects/stackspin%2Fstackspin/registry/repositories/73/tags/${CI_CONTAINER_TAG}; fi" - environment: - name: $CI_COMMIT_REF_SLUG - action: stop