File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : cleanup caches on pull request close
2
+
3
+ on :
4
+ pull_request :
5
+ types :
6
+ - closed
7
+
8
+ jobs :
9
+ cleanup :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - uses : actions/checkout@v3
14
+
15
+ - name : Cleanup
16
+ run : |
17
+ gh extension install actions/gh-actions-cache
18
+
19
+ REPO=${{ github.repository }}
20
+ BRANCH=${{ github.ref }}
21
+
22
+ echo "Fetching list of cache key"
23
+ cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
24
+
25
+ ## Setting this to not fail the workflow while deleting cache keys.
26
+ set +e
27
+
28
+ echo "Deleting caches..."
29
+ for cacheKey in $cacheKeysForPR
30
+ do
31
+ gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
32
+ done
33
+
34
+ echo "Done"
35
+ env :
36
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments