diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2eb8e9d768304508487ddd290df1d092bad8d753..8a673fc2ba6aa5d172f2a9fc7c4bb6034f8c7386 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ default: image: "archlinux:latest" stages: + - cleanup - lint - rootfs - image @@ -9,6 +10,23 @@ stages: - release - publish +cleanup: + stage: cleanup + tags: + - secure + only: + refs: + - schedules + variables: + - $CLEANUP_PACKAGE_REGISTRY == "TRUE" + before_script: + - pacman -Syu --noconfirm jq + script: + - | + for id in $(curl --silent --fail --show-error "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?per_page=100&order_by=created_at&sort=asc" | jq '.[] | select(.created_at | split("T")[0] | . < (now-60*60*24*60|strflocaltime("%Y-%m-%d"))) | .id'); do + curl --silent --fail --show-error --request DELETE --header "PRIVATE-TOKEN: ${GITLAB_PROJECT_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${id}" + done + lint: stage: lint image: hadolint/hadolint:latest-alpine