Commit 03e657b
authored
ci(docs): clean up PR previews on close + scheduled safety-net sweep (#1202)
## Problem
The `sentry docs` PR-preview link was returning **404** for new PRs
(e.g. #1201), while older previews still worked. Root cause:
- `docs-preview.yml` triggered on `pull_request` `[opened, synchronize,
reopened]` — **never `closed`** — so `rossjrw/pr-preview-action`'s
auto-cleanup never ran.
- **46 stale previews** (each a full copy of the docs site) accumulated
in `gh-pages`, pushing the **GitHub Pages build over its size/time
limits**. Builds started failing intermittently (`Page build failed`),
so newly-deployed previews 404'd while previously-published ones kept
serving.
## Fix (pattern ported from `getsentry/loreai`)
**`docs-preview.yml`**
- Add `closed` to the `pull_request` types and **remove the
`pull_request` paths filter** — a `closed` event must always fire so the
preview can be removed.
- A `dorny/paths-filter` step + a central **`gate`** step decide:
- `build` → push, or a docs PR being opened/updated (fork PRs still
build to surface compile errors).
- `deploy` → build, **or any `closed` event** (cleanup), never for fork
PRs.
- On close, `pr-preview-action` `action: auto` **removes** the preview —
the actual cleanup that was missing.
**`cleanup-doc-previews.yml` (new)**
- Weekly (`cron`) + `workflow_dispatch` **safety net**: sweeps
`gh-pages` for `_preview/pr-<n>` dirs whose PR is no longer `OPEN` and
removes them. Uses a **blobless, no-checkout clone + index rewrite**, so
it never downloads the (large) preview file contents. Catches anything
the on-close path misses (e.g. PRs closed while the workflow was broken
— exactly how we got here).
## Already done out-of-band
The 46 already-stale previews were pruned from `gh-pages` directly
(blobless index rewrite) to **unblock the failing Pages build
immediately** — previews now serve again (verified `pr-1201` → 200).
This PR prevents recurrence.
## Validation
- Both workflows: valid YAML; `actionlint` clean (only a pre-existing
SC2088 on the unchanged `--url-prefix "~/"` line, a deliberate Sentry
URL prefix).
- Gate logic walked through for push / docs-PR open+sync / non-docs PR /
close / fork / fork-close.1 parent 108d24d commit 03e657b
2 files changed
Lines changed: 160 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
43 | 81 | | |
| 82 | + | |
44 | 83 | | |
45 | 84 | | |
46 | 85 | | |
47 | 86 | | |
48 | 87 | | |
| 88 | + | |
49 | 89 | | |
50 | 90 | | |
51 | 91 | | |
52 | 92 | | |
53 | 93 | | |
| 94 | + | |
54 | 95 | | |
55 | 96 | | |
56 | 97 | | |
57 | 98 | | |
58 | | - | |
| 99 | + | |
59 | 100 | | |
60 | 101 | | |
61 | 102 | | |
62 | 103 | | |
| 104 | + | |
63 | 105 | | |
64 | 106 | | |
65 | 107 | | |
| 108 | + | |
66 | 109 | | |
67 | 110 | | |
68 | 111 | | |
| 112 | + | |
69 | 113 | | |
70 | 114 | | |
71 | 115 | | |
| |||
79 | 123 | | |
80 | 124 | | |
81 | 125 | | |
82 | | - | |
| 126 | + | |
83 | 127 | | |
84 | 128 | | |
85 | 129 | | |
| |||
92 | 136 | | |
93 | 137 | | |
94 | 138 | | |
| 139 | + | |
95 | 140 | | |
96 | 141 | | |
97 | 142 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
102 | 146 | | |
103 | 147 | | |
104 | 148 | | |
| |||
130 | 174 | | |
131 | 175 | | |
132 | 176 | | |
133 | | - | |
134 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
135 | 181 | | |
136 | 182 | | |
137 | 183 | | |
| |||
0 commit comments