From 42217307317d6d93e5962fe0837eeafaa9060a4f Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Wed, 11 May 2022 11:08:34 +0200 Subject: [PATCH] added cleanup job --- .gitlab/ci/cleanup_tags.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .gitlab/ci/cleanup_tags.yml diff --git a/.gitlab/ci/cleanup_tags.yml b/.gitlab/ci/cleanup_tags.yml new file mode 100644 index 000000000..bd04c26f9 --- /dev/null +++ b/.gitlab/ci/cleanup_tags.yml @@ -0,0 +1,22 @@ +.cleanup_tags: + stage: deploy + image: curlimages/curl + variables: + FPM_IMAGE_REPOSITORY_ID: 415 + NGINX_IMAGE_REPOSITORY_ID: 416 + API_DELETE_PATH: /projects/$CI_PROJECT_ID/registry/repositories/:repository_id/tags + script: + # Delete all composer image tags for this branch as we don't need them anymore + - > + curl -X DELETE -k -H 'Content-Type: application/json' + -H "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" + -i "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/registry/repositories/${FPM_IMAGE_REPOSITORY_ID}/tags" + --data "{\"name_regex_delete\": \"$CI_COMMIT_REF_SLUG-composer-.*\"}" + +cleanup_tags_review: + extends: cleanup_tags + rules: + - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "development"' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + \ No newline at end of file -- GitLab