From b904e68f503e29e3181bd55c16c93f9703b52b18 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Tue, 24 Jun 2025 13:00:40 -0400 Subject: [PATCH] ci: remove all PR caches on close - .github/workflows/cleanup-caches.yml: add while loop to remove caches until none are left. - print cache ids as they are deleted Signed-off-by: Aiden Woodruff --- .github/workflows/cleanup-caches.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cleanup-caches.yml b/.github/workflows/cleanup-caches.yml index 2f666007a..c268da8e6 100644 --- a/.github/workflows/cleanup-caches.yml +++ b/.github/workflows/cleanup-caches.yml @@ -13,15 +13,13 @@ jobs: run: | echo "Fetching list of cache keys" cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id') - - ## Setting this to not fail the workflow while deleting cache keys. - set +e - echo "Deleting caches..." - for cacheKey in $cacheKeysForPR - do - gh cache delete $cacheKey + while [ "$cacheKeysForPR" ]; do + for cacheKey in $cacheKeysForPR; do + echo gh cache delete $cacheKey + gh cache delete $cacheKey + done + cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id') done - echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }}