diff --git a/.gitlab/ci/cleanup_tags.yml b/.gitlab/ci/cleanup_tags.yml index c02e632cf6260e191ffca9b1252b4b8bdc56799b..b18baaf3feeba98540d212798c801014e7f12b4d 100644 --- a/.gitlab/ci/cleanup_tags.yml +++ b/.gitlab/ci/cleanup_tags.yml @@ -6,14 +6,25 @@ NGINX_IMAGE_REPOSITORY_ID: 416 script: | # Delete all composer image tags for this branch as we don't need them anymore - echo "PRIVATE-TOKEN: $CI_JOB_TOKEN" curl -X DELETE -k -H 'Content-Type: application/json' --fail \ -H "JOB-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-.*\"}" + # Delete all fpm tags but keeping the latest n ones (1 for review apps and 10 for development/master) + curl -X DELETE -k -H 'Content-Type: application/json' --fail \ + -H "JOB-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-.*\", \"keep_n\": $KEEP_TAGS}" + # Delete all nginx tags but keeping the latest n ones (1 for review apps and 10 for development/master) + curl -X DELETE -k -H 'Content-Type: application/json' --fail \ + -H "JOB-TOKEN: ${CI_JOB_TOKEN}" \ + -i "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/registry/repositories/${NGINX_IMAGE_REPOSITORY_ID}/tags" \ + --data "{\"name_regex_delete\": \"$CI_COMMIT_REF_SLUG-.*\", \"keep_n\": $KEEP_TAGS}" cleanup_tags_review: extends: .cleanup_tags + variables: + KEEP_TAGS: 1 rules: - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "development"' when: never