Commit ff85922
fix(ci): replace PR promotion with squash push in promote-to-lts (#1177)
## Problem
The `promote-to-lts.yml` workflow has caused repeated git tree pollution
on `lts`. After digging through the full history, here is the root cause
chain:
1. **Circular history reference**: `ffa30fe` (`Merge branch 'lts' into
main`) accidentally merged `lts` → `main`, embedding lts's pull-bot
merge commits inside main's graph.
2. **lts has diverged**: 4 commits exist in `lts` that aren't in `main`
(old pull-bot merges + the `2a780d2` emergency CI sync).
3. **Default merge commit strategy**: The previous `gh pr create --head
main` approach created a PR that, when merged with GitHub's default
button, produced a merge commit with two parents. That commit dragged
main's full cross-contaminated history into `lts` on every promotion,
deepening the diamond graph each time.
4. **No pre-flight guard**: Nothing prevented the workflow from running
when `lts` was already in a diverged state.
## Solution
Replace the PR creation step with a direct **squash push**:
1. **Pre-flight check** — `git rev-list origin/lts ^origin/main
--count`. If > 0, fail immediately and list the divergent commits with
instructions to land them in `main` first.
2. **`git merge --squash origin/main`** — collapses all pending main
changes into a single staged changeset. No merge commit. No embedded
history.
3. **One clean commit** pushed to `lts` per promotion event → linear
history.
The `workflow_dispatch` trigger is the human approval gate — a
maintainer must explicitly trigger the workflow to promote.
## Why not keep the PR?
Previous attempts:
| Approach | Why it failed |
|---|---|
| Old Pull bot | Created `[pull]` merge commits; also ran in reverse |
| Intermediate branch + PR | Merge commit still polluted `lts` on merge
|
| `gh pr create --head main` (last fix) | PR merged with default
strategy = merge commit |
| Direct file sync `2a780d2` | Added lts-unique commits, deepening
divergence |
A squash push is deterministic — the workflow controls the merge
strategy, not the human clicking the merge button.
## Changes
- `.github/workflows/promote-to-lts.yml`: Replace `gh pr create` with
checkout + pre-flight + squash merge + push. Swap `pull-requests: write`
→ `contents: write`.
- `AGENTS.md`: Update promotion flow description; add **NEVER commit
directly to `lts`** rule.
## 1 parent a527168 commit ff85922
2 files changed
+63
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 14 | + | |
18 | 15 | | |
19 | 16 | | |
20 | | - | |
21 | | - | |
| 17 | + | |
22 | 18 | | |
23 | 19 | | |
24 | | - | |
| 20 | + | |
25 | 21 | | |
26 | 22 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
266 | | - | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
0 commit comments