Skip to content

Commit

Permalink
CI: Delete all cache if there's more than 100 entries
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Oct 23, 2024
1 parent 38d0c86 commit 8d345b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/delete-pr-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 8d345b8

Please sign in to comment.