Commit d618a61
authored
ci: reduce Actions cache usage and fix cleanup (#4123)
Reduce GitHub Actions cache pressure by keeping main as the authoritative Docker BuildKit cache producer and making cache cleanup reliable for pull requests and deleted branches.
Cache cleanup:
- Run closed pull request cleanup through pull_request_target so the workflow receives the actions: write permission required to remove caches created by fork-owned PRs.
- Keep the privileged cleanup safe by avoiding checkout or execution of pull request code.
- Replace the previous cache listing and extension loop with gh cache delete --all scoped to the exact pull request merge ref.
- Stop suppressing cache deletion failures so permission and API errors are reported instead of producing misleading successful runs.
- Add cleanup for caches associated with deleted branches, including temporary dependency-update branches.
- Use --succeed-on-no-caches so already-clean refs remain valid cleanup runs.
Docker cache behavior:
- Make pull request Docker builds restore-only.
- Allow PR builds to reuse the shared GitHub Actions BuildKit cache without exporting their own full mode=max cache.
- Keep main as the only producer of the complete reusable BuildKit cache.
- Make main cache-export backend or quota failures non-blocking so a successful Docker image build is not failed only because the cache could not be published.
Measured impact:
- Removed 178 legacy PR-scoped BuildKit caches.
- Reclaimed 9.531 GiB of Actions cache storage.
- Reduced repository cache usage from 10.088 GiB to 0.557 GiB, about 94.5% lower.
- Preserved the default-branch BuildKit cache and existing mise, ccache, map, and other non-BuildKit caches.
- Confirmed the PR Docker build completed without creating a cache under refs/pull/4123/merge.
Validation:
- Passed actionlint for clean-cache.yaml and reusable-build-docker.yml.
- Passed git diff --check.
- Passed GitHub Actions yamllint, fast checks, Lua checks, cppcheck, SonarCloud, Docker image build, and Docker quickstart smoke.
- Completed the one-time legacy cache cleanup with no deletion failures.
- Event-driven cleanup jobs were validated statically and will execute from the default branch after merge.
This prevents closed PRs and deleted branches from accumulating stale Actions caches while avoiding a separate full Docker cache for every pull request.1 parent 87c35d7 commit d618a61
2 files changed
Lines changed: 36 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | | - | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
11 | 20 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
18 | 30 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
27 | 39 | | |
28 | 40 | | |
29 | | - | |
30 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
0 commit comments