File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Delete Cache after PR merge
2+
3+ on :
4+ pull_request :
5+ types :
6+ - closed
7+
8+ permissions :
9+ contents : read
10+ actions : write
11+
12+ jobs :
13+ cleanup :
14+ name : Clear cache
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout repository
19+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+ with :
21+ fetch-depth : 0
22+
23+ - name : Cleanup
24+ run : |
25+ gh extension install actions/gh-actions-cache
26+
27+ REPO=${{ github.repository }}
28+
29+ # get the branch
30+ BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
31+
32+ # fetch list of cache key
33+ cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
34+
35+ # set this to not fail the workflow while deleting cache keys
36+ set +e
37+
38+ # delete cache key
39+ for cacheKey in $cacheKeysForPR
40+ do
41+ gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
42+ done
43+ env :
44+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 99permissions :
1010 actions : read
1111 contents : write
12+ pull-requests : write
1213
1314concurrency :
1415 group : publish-nuget
You can’t perform that action at this time.
0 commit comments