We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00936e8 commit 441fb04Copy full SHA for 441fb04
.github/workflows/cleanup-cache.yml
@@ -0,0 +1,29 @@
1
+name: Cleanup caches on closed PRs
2
+on:
3
+ pull_request:
4
+ types:
5
+ - closed
6
+
7
+jobs:
8
+ cleanup:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ actions: write
12
+ steps:
13
+ - name: Cleanup
14
+ env:
15
+ GH_TOKEN: ${{ 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 keys"
20
+ cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
21
22
+ ## Setting this to not fail the workflow while deleting cache keys.
23
+ set +e
24
+ echo "Deleting caches..."
25
+ for cacheKey in $cacheKeysForPR
26
+ do
27
+ gh cache delete $cacheKey
28
+ done
29
+ echo "Done"
0 commit comments