From c81649e58f9cac5d48fbfca4eb857f5d2ddc2156 Mon Sep 17 00:00:00 2001 From: German Date: Tue, 19 Mar 2024 11:46:23 +0100 Subject: [PATCH] Using while in cache cleaner branch side --- .github/workflows/cache_cleaner.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cache_cleaner.yml b/.github/workflows/cache_cleaner.yml index 3f32fcc03b..638e944e2d 100644 --- a/.github/workflows/cache_cleaner.yml +++ b/.github/workflows/cache_cleaner.yml @@ -26,9 +26,15 @@ jobs: ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in $cacheKeysForPR + + while [ ! -z "$cacheKeysForPR" ]; do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm && echo "Deleting cache with key: $cacheKey" + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm && echo "Deleting cache with key: $cacheKey" + done + + cacheKeysForPR=$(gh actions-cache list -R $REPO | cut -f 1 ) done echo "Done" env: @@ -48,9 +54,14 @@ jobs: ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in $cacheKeysForPR + while [ ! -z "$cacheKeysForPR" ]; do - gh actions-cache delete $cacheKey -R $REPO --confirm && echo "Deleting cache with key: $cacheKey" + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO --confirm && echo "Deleting cache with key: $cacheKey" + done + + cacheKeysForPR=$(gh actions-cache list -R $REPO | cut -f 1 ) done echo "Done" env: