diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7bcebe94c3114f7927b7cafea0fd67034c4a2824..4f107b738b85ac57da82e59876f568b89d0846b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -226,7 +226,6 @@ ci-test-image-build: environment: name: image/$CI_COMMIT_REF_SLUG url: https://open.greenhost.net:4567/openappstack/openappstack/openappstack-ci:${CI_COMMIT_REF_SLUG} - on_stop: delete-image auto_stop_in: 3 weeks rules: # Automatically rebuild the container image if this file, the Dockerfile, @@ -698,7 +697,7 @@ wordpress-taiko: # === -# Terminates a droplet once the branch for it is deleted +# 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 @@ -709,24 +708,10 @@ terminate-droplet: 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\" != \"master\" ]; then curl --request DELETE --header \"PRIVATE-TOKEN: ${CLEANER_TOKEN}\" https://open.greenhost.net/api/v4/projects/openappstack%2Fopenappstack/registry/repositories/2/tags/${CI_CONTAINER_TAG}; fi" environment: name: $CI_COMMIT_REF_SLUG action: stop - -# Deletes a container image once a branch is deleted. -# Careful! When you run this step manually, you might have to trigger container -# image re-build as well -delete-image: - # Should be in the post-build stage so it automatically gets the artifacts it - # that contain the CI_COMMIT_REF_SLUG variable - stage: create-vps - when: manual - variables: - GIT_STRATEGY: none - script: - - *debug_information - - "curl --request DELETE --header \"PRIVATE-TOKEN: ${CLEANER_TOKEN}\" https://open.greenhost.net/api/v4/projects/openappstack%2Fopenappstack/registry/repositories/2/tags/${CI_COMMIT_REF_SLUG}" - environment: - name: image/$CI_COMMIT_REF_SLUG - action: stop