We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00936e8 commit 0b4a001Copy full SHA for 0b4a001
1 file changed
.github/workflows/cleanup-cache.yml
@@ -0,0 +1,32 @@
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"
0 commit comments