Fallout-build / Fallout-build/Fallout

Purge a pull request's Actions caches when it closes

Open
#649 0 comments 0 reactions 0 assignees View on GitHub
CD enhancement
Dominant language
C#
Stars
154
Forks
19
Avg merge
1d 22h
Merged PRs (30d)
15

Description

### Problem
Actions caches created for a pull request are never deleted when that pull request closes. They stay until GitHub evicts them after 7 days of no access. On 2026-08-19 this organisation held 5.95 GB of caches, and 4.3 GB of that was unused caches belonging to pull requests that were already merged or closed. Each repository on the Free plan gets 10 GB of cache. Filling it wastes the allowance and produces billing alert emails.

### Outcome
When a pull request closes, the caches that belong only to that pull request are deleted automatically. No manual cleanup is needed.

### Acceptance criteria
- [ ] A workflow runs on `pull_request` with `types: [closed]`.
- [ ] It deletes every cache whose `ref` is `refs/pull//merge` for the pull request that just closed.
- [ ] It uses the built-in `GITHUB_TOKEN` with `permissions: actions: write`, not a personal access token.
- [ ] The run succeeds when the pull request has no caches.
- [ ] Caches on branch refs such as `refs/heads/main` and `refs/heads/release/*` are not touched.

### Notes
- One cache on this repository was 589 MB for a single pull request (#640). It was deleted by hand on 2026-08-19.
- List caches with `GET /repos/{owner}/{repo}/actions/caches`, delete with `DELETE /repos/{owner}/{repo}/actions/caches/{cache_id}`.
- The same problem exists in `Fallout.Extensions.VSCode`, tracked in Fallout-build/Fallout.Extensions.VSCode#25.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.