-
-
Notifications
You must be signed in to change notification settings - Fork 432
26 lines (24 loc) · 742 Bytes
/
clear-cache.yaml
File metadata and controls
26 lines (24 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
name: Clear PR caches
on:
pull_request:
# triggers on close / merge of a PR
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup caches for closed PR
# remove all cache entries for this PR
# caches usability hierarchy : master → PR
# other PRs / master cannot reuse them
# so clear them when the PR is closed or merged
run: |
gh cache list --ref refs/pull/${{ github.event.pull_request.number }}/merge --json id \
| jq -r '.[].id' \
| xargs -I{} gh cache delete {}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}