We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2a827ab commit e0c23cdCopy full SHA for e0c23cd
.github/workflows/cache-cleanup.yml
@@ -0,0 +1,30 @@
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 }}
0 commit comments