Commit fd93a52
authored
Fix Drift: authenticate via copilotkit-devops-bot app token (#305)
## Problem
The Fix Drift workflow was using `GITHUB_TOKEN` for every authenticated
operation (git push, PR create, auto-merge). This has two critical
consequences:
1. **PRs created by `GITHUB_TOKEN` don't trigger `pull_request` events**
— GitHub suppresses the event to prevent recursive workflows, so drift
fix PRs never get CI checks.
2. **`github-actions[bot]` can't satisfy main's approval rule** — the
bot identity is not a permitted bypass actor, so even if CI somehow ran,
the PR couldn't auto-merge.
## Fix
Mint a copilotkit-devops-bot (app-id `1108748`) installation token early
in the job using `actions/create-github-app-token`, then use that token
for all three authenticated operations:
- `Configure git for push` — injects the token into the git URL so the
fix branch push is attributable to the bot
- `Create PR` — `GH_TOKEN` is the bot token, so `gh pr create` runs as
devops-bot; GitHub fires `pull_request` — CI triggers
- `Auto-merge PR` — `GH_TOKEN` is the bot token; devops-bot is a scoped
Integration bypass actor on main's ruleset
**Required secret:** `DEVOPS_BOT_PRIVATE_KEY` must be added to the
repo/org Actions secrets (being added separately).
**Required ruleset entry:** devops-bot must be added as an Integration
bypass actor on main's ruleset (being added separately).
## In-workflow CI green gate
A ruleset bypass actor bypasses the **entire** ruleset — including any
required-status-checks rule. This means a bypassing actor's PR can merge
immediately without waiting for CI. To prevent merging on a red or empty
build:
- Poll until at least one check is registered (up to 10 x 30 s = 5 min);
fail hard if none ever appear
- Run `gh pr checks --watch --fail-fast` to block until all checks pass;
exit non-zero kills the step
- Only then call `gh pr merge --merge` (no `--auto` — we do the waiting
ourselves)
This makes CI-green a hard precondition enforced in the workflow, not
the ruleset.
## Diff summary
| Location | Change |
|---|---|
| After `actions/checkout` | Add `Mint app token` step (id: `app-token`)
using `actions/create-github-app-token` pinned to v3.2.0 |
| `Configure git for push` env | `GITHUB_TOKEN` replaced with
`steps.app-token.outputs.token` |
| `Create PR` env | `GITHUB_TOKEN` replaced with
`steps.app-token.outputs.token` |
| `Auto-merge PR` env + run | `GITHUB_TOKEN` replaced with
`steps.app-token.outputs.token`; one-liner `gh pr merge --auto` replaced
with poll-then-watch-then-merge guard |
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 file changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
| |||
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
139 | | - | |
| 147 | + | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
146 | | - | |
| 154 | + | |
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| |||
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
157 | | - | |
| 165 | + | |
158 | 166 | | |
159 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
160 | 193 | | |
161 | 194 | | |
162 | 195 | | |
| |||
0 commit comments