Skip to content

Commit a9d121c

Browse files
cubehouseclaude
andauthored
ci(drift): open the PR as a GitHub App so its checks actually run (#38)
The drift job opened its PR with GITHUB_TOKEN. GitHub does not start workflow runs from GITHUB_TOKEN-raised events, so the required Test (Node ...) checks never reported and the PR was blocked on a report it could not receive. #34 has sat that way since 2026-09-02 while its body said 'build: success'. Fixed by minting a short-lived installation token from the tpw-drift app and handing it to create-pull-request. The push then comes from the app's identity rather than GITHUB_TOKEN, pull_request fires normally, and CI reports. The app holds contents:write and pull_requests:write on two repos and nothing else — notably not workflows:write, so it cannot alter CI. The create-an-issue steps keep GITHUB_TOKEN deliberately. They open issues on failure, an issue does not need to trigger anything, and there is no reason to widen the app's reach. Also corrects the comment left on ci.yml's workflow_dispatch trigger by the previous attempt. workflow_dispatch is genuinely a documented exception to the no-runs rule, and it does start a run — but that run's check runs do not satisfy branch protection. Measured, not assumed: on one PR, a dispatched run put three successful check runs with the exact required names on the head SHA and left it BLOCKED with an empty rollup for two minutes, while a push-event run on the next commit cleared it at once. The trigger is kept because re-running CI against a ref by hand is useful; the claim that it fixes drift is removed. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8884361 commit a9d121c

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ on:
55
branches: [main, v7]
66
pull_request:
77
branches: [main, v7]
8-
# Lets another workflow start this one against a specific ref.
8+
# Re-run CI against a ref by hand. Convenience only.
99
#
10-
# The spec-drift job opens its PR with GITHUB_TOKEN, and GitHub does not
11-
# start workflow runs from GITHUB_TOKEN-raised events — so the required
12-
# checks never report and the PR is blocked on a report it can never get.
13-
# workflow_dispatch and repository_dispatch are the two documented
14-
# exceptions to that rule, so drift can dispatch this run itself.
10+
# This was added to let the spec-drift job start its own CI, on the reasoning
11+
# that workflow_dispatch is a documented exception to "GITHUB_TOKEN-raised
12+
# events do not start workflow runs". The run does start — but measured
13+
# against a real PR, its check runs do not satisfy branch protection, even
14+
# sitting on the PR head SHA with the exact required names and a check suite
15+
# reporting as linked to the PR. A push-event run on the next commit cleared
16+
# the same PR immediately. Drift therefore pushes as a GitHub App instead;
17+
# see spec-drift.yml. Kept because dispatching CI by hand is still useful.
1518
workflow_dispatch:
1619

1720
jobs:

‎.github/workflows/spec-drift.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,27 @@ jobs:
3737
continue-on-error: true
3838
run: npm run test:live
3939

40+
# The PR must not be opened with GITHUB_TOKEN. GitHub does not start
41+
# workflow runs from GITHUB_TOKEN-raised events, so a PR opened that way
42+
# never gets its required checks and can never be merged, however good
43+
# the diff is. Both drift PRs sat blocked for days on exactly that.
44+
#
45+
# workflow_dispatch is documented as an exception to the no-runs rule and
46+
# does start a run — but measured against a real PR, those check runs do
47+
# not satisfy branch protection even on the right SHA under the right
48+
# names. A push-event run does. So the push has to come from an identity
49+
# that is not GITHUB_TOKEN, and this app is that identity.
50+
- name: Mint an installation token for the drift bot
51+
id: app-token
52+
uses: actions/create-github-app-token@v2
53+
with:
54+
app-id: ${{ secrets.DRIFT_APP_ID }}
55+
private-key: ${{ secrets.DRIFT_APP_PRIVATE_KEY }}
56+
4057
- name: Open PR if schema changed
4158
uses: peter-evans/create-pull-request@v8
4259
with:
60+
token: ${{ steps.app-token.outputs.token }}
4361
add-paths: src/_generated/schema.ts
4462
branch: automated/spec-drift
4563
commit-message: 'chore: regenerate schema from upstream spec'

0 commit comments

Comments
 (0)