Skip to content

Commit b904e68

Browse files
committed
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 <[email protected]>
1 parent 1049872 commit b904e68

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

.github/workflows/cleanup-caches.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ jobs:
1313
run: |
1414
echo "Fetching list of cache keys"
1515
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
16-
17-
## Setting this to not fail the workflow while deleting cache keys.
18-
set +e
19-
echo "Deleting caches..."
20-
for cacheKey in $cacheKeysForPR
21-
do
22-
gh cache delete $cacheKey
16+
while [ "$cacheKeysForPR" ]; do
17+
for cacheKey in $cacheKeysForPR; do
18+
echo gh cache delete $cacheKey
19+
gh cache delete $cacheKey
20+
done
21+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
2322
done
24-
echo "Done"
2523
env:
2624
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2725
GH_REPO: ${{ github.repository }}

0 commit comments

Comments
 (0)