Skip to content

Commit e936df4

Browse files
committed
Fix cleanup-caches workflow for fork PRs
pull_request events from forks ship a read-only GITHUB_TOKEN regardless of the permissions: block, so gh cache delete fails with HTTP 403 and the fork PR's ~1-2 GB of caches leak into the repo's 10 GB cache budget. Observed on PR #14374 (8/8 deletes returned 403, run succeeded because set +e swallowed the failures). pull_request_target runs in the base-branch context with full write permissions. Safe for this workflow: no PR code is checked out, the steps only call gh cache list/delete.
1 parent 90d5fb6 commit e936df4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/cleanup-caches.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Cleanup github runner caches on closed pull requests
22
on:
3-
pull_request:
3+
# pull_request_target is required so fork PRs can delete their own caches on close.
4+
# pull_request from a fork ships a read-only GITHUB_TOKEN regardless of the
5+
# permissions: block, causing gh cache delete to fail with HTTP 403.
6+
# Safe here: no PR code is checked out, the workflow only calls gh cache list/delete.
7+
pull_request_target:
48
types:
59
- closed
610

0 commit comments

Comments
 (0)