Skip to content

clear-caches

clear-caches #133

Workflow file for this run

name: clear-caches
on: workflow_dispatch
jobs:
clear:
name: Clear all caches
runs-on: ubuntu-latest
steps:
- run: |
TOTAL_COUNT=0
while true; do
LIST_CACHES=$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/actions/caches)
REMAINING_COUNT=$(echo $LIST_CACHES | jq .total_count)
[[ $REMAINING_COUNT > 0 ]] || break
IDS=$(echo $LIST_CACHES | jq .actions_caches[].id)
for ID in ${IDS[@]}; do
echo "Clearing $ID"
gh api --method DELETE -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/actions/caches/$ID
TOTAL_COUNT=$((TOTAL_COUNT + 1))
done
done
echo "Cleared $TOTAL_COUNT caches"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}