Commit 906ca64
authored
add backtrack workflow with branch locking to prevent race conditions (#185)
## Summary
Adds `.github/workflows/backtrack.yml` — an automated workflow that
back-merges changes from higher branches into lower branches after a PR
is merged, with branch locking to prevent race conditions.
## Background
Currently the back-merges (e.g. `Merge branch 'preview/1.0' into
develop/1.0`) are done manually. Without any coordination, a developer
could push a commit to `develop/M.n` between the moment the workflow
reads the branch tip and when it pushes the merge — causing the push to
fail or producing an incorrect merge base.
## What the workflow does
**Trigger**: any PR that is _merged_ into `preview/**` or `release/**`
| Source (base_ref) | Backtrack cascade |
|---|---|
| `preview/M.n` | `preview/M.n → develop/M.n` |
| `release/M.n` | `release/M.n → preview/M.n → develop/M.n` |
**Race-condition protection**:
1. `develop/M.n` is **locked** (branch protection applied) before any
merge begins — blocking concurrent direct pushes from developers.
2. All pushes use `GH_ADMIN_TOKEN`, which bypasses `enforce_admins:
false` protection — so the workflow can push even to a locked branch.
3. `develop/M.n` is **unlocked** in an `always()` step keyed on
`steps.lock-develop.outcome != 'skipped'` — ensures cleanup even if a
merge fails.
4. `preview/M.n` is already permanently locked by `promote-branch.yml`
and does not need extra lock/unlock steps; the admin token bypasses it
for the release→preview merge.
## Impact on other workflows
- **`bump-version.yml`**: unaffected — it creates brand-new branches via
`workflow_dispatch` (no PR merge event) and pushes to branches that have
no protection yet.
- **`promote-branch.yml`**: unaffected — it handles forward promotion
and creates/locks branches on first creation.
- **`release.yml`**: unaffected — it handles building, publishing, and
creating support branches.1 parent 314d35e commit 906ca64
1 file changed
Lines changed: 107 additions & 0 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 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
0 commit comments