clear-caches #133
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |