Skip to content

Commit bbdd28a

Browse files
committed
Clean up PR caches on close
1 parent 3cd6b74 commit bbdd28a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Clean up PR caches
2+
3+
# A PR's caches are scoped to refs/pull/<n>/merge and can't be reused by any
4+
# other branch or PR, so once it closes they just waste the repo's shared
5+
# 10 GB budget until eviction. Delete on close to free space.
6+
7+
on:
8+
pull_request:
9+
types: [closed]
10+
11+
permissions: {}
12+
13+
jobs:
14+
cleanup:
15+
name: Delete caches for the closed PR
16+
runs-on: ubuntu-slim
17+
permissions:
18+
actions: write # Required to delete Actions caches
19+
env:
20+
GH_FORCE_TTY: "120"
21+
GH_REPO: ${{ github.repository }}
22+
GH_TOKEN: ${{ github.token }}
23+
PR_REF: refs/pull/${{ github.event.pull_request.number }}/merge
24+
steps:
25+
- name: List caches scoped to this PR
26+
run: gh cache list --ref "${PR_REF}"
27+
- name: Delete caches scoped to this PR
28+
run: gh cache delete --all --ref "${PR_REF}" --succeed-on-no-caches

0 commit comments

Comments
 (0)