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