From 8d345b88c02b669f320268f114696ed09d021673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Tue, 22 Oct 2024 11:38:10 +0200 Subject: [PATCH] CI: Delete all cache if there's more than 100 entries --- .github/workflows/delete-pr-cache.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/delete-pr-cache.yml b/.github/workflows/delete-pr-cache.yml index 38005aaf3..be30e007e 100644 --- a/.github/workflows/delete-pr-cache.yml +++ b/.github/workflows/delete-pr-cache.yml @@ -13,10 +13,16 @@ jobs: gh extension install actions/gh-actions-cache REPO='${{ github.repository }}' BRANCH='refs/pull/${{ github.event.pull_request.number }}/merge' - readarray -t CACHE_KEYS < <(gh actions-cache list --repo "$REPO" --branch "$BRANCH" --limit 100 | cut --fields=1) - for CACHE_KEY in "${CACHE_KEYS[@]}"; do - gh actions-cache delete "$CACHE_KEY" --repo "$REPO" --branch "$BRANCH" --confirm + while true; do + readarray -t CACHE_KEYS < <(gh actions-cache list --repo "$REPO" --branch "$BRANCH" --limit 100 | cut --fields=1) + if [[ "${#CACHE_KEYS[@]}" -eq 0 ]]; then + break + fi + + for CACHE_KEY in "${CACHE_KEYS[@]}"; do + gh actions-cache delete "$CACHE_KEY" --repo "$REPO" --branch "$BRANCH" --confirm + done done env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}