Skip to content

Commit 704847c

Browse files
committed
Clear cache on close/merge of PR
1 parent 0d96edd commit 704847c

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

.github/workflows/clear-cache.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Clear PR caches
2+
3+
on:
4+
pull_request:
5+
# triggers on close / merge of a PR
6+
types:
7+
- closed
8+
9+
jobs:
10+
cleanup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Cleanup caches for closed PR
14+
# remove all cache entries for this PR
15+
# caches usability hierarchy : master → PR
16+
# other PRs / master cannot reuse them
17+
# so clear them when the PR is closed or merged
18+
run: |
19+
gh cache list --ref ${{ github.ref }} --json id \
20+
| jq -r '.[].id' \
21+
| xargs -I{} gh cache delete {}
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
GH_REPO: ${{ github.repository }}

.github/workflows/stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
- name: Build
7979
# builds tests but does not run them
8080
run: |
81-
stack -j2 \
81+
stack \
8282
--stack-yaml=${{ matrix.stack-yaml }} \
8383
--system-ghc \
8484
--no-terminal \

0 commit comments

Comments
 (0)