Skip to content
Snippets Groups Projects
Verified Commit ff93df5f authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

delete droplet before container

parent dcd2a3b0
No related branches found
No related tags found
No related merge requests found
...@@ -226,7 +226,6 @@ ci-test-image-build: ...@@ -226,7 +226,6 @@ ci-test-image-build:
environment: environment:
name: image/$CI_COMMIT_REF_SLUG name: image/$CI_COMMIT_REF_SLUG
url: https://open.greenhost.net:4567/openappstack/openappstack/openappstack-ci:${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 auto_stop_in: 3 weeks
rules: rules:
# Automatically rebuild the container image if this file, the Dockerfile, # Automatically rebuild the container image if this file, the Dockerfile,
...@@ -698,7 +697,7 @@ wordpress-taiko: ...@@ -698,7 +697,7 @@ wordpress-taiko:
# === # ===
# Terminates a droplet once the branch for it is deleted # Terminates a droplet and deletes a container once the MR for it is merged
terminate-droplet: terminate-droplet:
# Stage has to be the same as the step that created the VPS # 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 # https://docs.gitlab.com/ee/ci/environments.html#automatically-stopping-an-environment
...@@ -709,24 +708,10 @@ terminate-droplet: ...@@ -709,24 +708,10 @@ terminate-droplet:
GIT_STRATEGY: none GIT_STRATEGY: none
script: script:
- *debug_information - *debug_information
# Delete droplet
- python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${CI_COMMIT_REF_SLUG}\")" - python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${CI_COMMIT_REF_SLUG}\")"
# Delete container if one was created
- "if [ ! -z \"$CI_CONTAINER_TAG\" ]; 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: environment:
name: $CI_COMMIT_REF_SLUG name: $CI_COMMIT_REF_SLUG
action: stop 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment