Skip to content

Commit 441fb04

Browse files
committed
chore: cleanup cache for closed PRs
1 parent 00936e8 commit 441fb04

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)