File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ # https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches
2+ name : Cleanup github runner caches on closed pull requests
3+ on :
4+ pull_request :
5+ types :
6+ - closed
7+
8+ jobs :
9+ cleanup :
10+ runs-on : ubuntu-latest
11+ permissions :
12+ actions : write
13+ steps :
14+ - name : Cleanup
15+ run : |
16+ echo "Fetching list of cache keys"
17+ cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
18+
19+ ## Setting this to not fail the workflow while deleting cache keys.
20+ set +e
21+ echo "Deleting caches..."
22+ for cacheKey in $cacheKeysForPR
23+ do
24+ gh cache delete $cacheKey
25+ done
26+ echo "Done"
27+ env :
28+ GH_TOKEN : ${{ github.token }}
29+ GH_REPO : ${{ github.repository }}
30+ BRANCH : refs/pull/${{ github.event.pull_request.number }}/merge
You can’t perform that action at this time.
0 commit comments