File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
2+ name : 🧹 Cache Cleanup
3+ on :
4+ pull_request :
5+ types :
6+ - closed
7+
8+ jobs :
9+ cleanup :
10+ name : Cleanup PR caches
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Cleanup
14+ env :
15+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16+ GH_REPO : ${{ github.repository }}
17+ BRANCH : refs/pull/${{ github.event.pull_request.number }}/merge
18+ run : |
19+ echo "Fetching list of cache key"
20+ cache_keys_for_pr=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
21+ # Setting this to not fail the workflow while deleting cache keys.
22+ set +e
23+ echo "Deleting caches..."
24+ for cache_key in $cache_keys_for_pr; do
25+ gh cache delete $cache_key
26+ echo "Deleted: $cache_key"
27+ done
28+ echo "Done"
You can’t perform that action at this time.
0 commit comments