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
+ name : Clean closed branch caches
2
+ on :
3
+ pull_request :
4
+ types :
5
+ - closed
6
+
7
+ jobs :
8
+ cleanup :
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - name : Clean Cache
12
+ run : |
13
+ gh extension install actions/gh-actions-cache
14
+
15
+ REPO=${{ github.repository }}
16
+ BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
17
+
18
+ echo "Fetching list of cache key"
19
+ cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
20
+
21
+ ## Setting this to not fail the workflow while deleting cache keys.
22
+ set +e
23
+ echo "Deleting caches..."
24
+ for cacheKey in $cacheKeysForPR
25
+ do
26
+ gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
27
+ done
28
+ echo "Done"
29
+ env :
30
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments