Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

Commit bdd906d

Browse files
committed
fix(ci): wait for a real check-run to register before requesting auto-merge
The App-token fix made this repo's own ci.yml pull_request checks genuinely cascade, but gh pr merge --auto still ran immediately after opening the PR -- before GitHub had actually registered any check-run against it. GitHub's enablePullRequestAutoMerge mutation rejects a PR it considers already 'clean', which a brand-new PR with zero registered checks trivially is, regardless of whether checks are about to start. Confirmed happening in production even with the App-token fix already live. This polls for ci.yml's own Test check-run to actually appear (bounded at 90s) before calling gh pr merge --auto, closing the race for real.
1 parent 544de5e commit bdd906d

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

.github/workflows/sibling-dependency-update.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Sibling dependency instant update
22

3-
# Triggered the moment a sibling ExaDev package this repo depends on publishes a new version -- the publishing repo own ci.yml sends this repository_dispatch event right after semantic-release completes, instead of waiting for Dependabot own daily scheduled scan to notice. Bumps the named dependency, opens a PR, and requests auto-merge. The branch push and the PR-open call both authenticate via a freshly-minted GitHub App installation token, not the default GITHUB_TOKEN -- GITHUB_TOKEN-authenticated actions (a push OR opening a PR) do not cascade into further workflow runs, so a GITHUB_TOKEN-created PR would never trigger this repo own ci.yml pull_request checks at all, leaving nothing for auto-merge to wait on and letting GitHub treat the PR as already mergeable the instant it opens. This workflow never pushes directly to main -- the PR still only merges once this repo own CI genuinely passes on it. Note: every repo in this family also enforces a minimumReleaseAge pnpm supply-chain gate (see pnpm-workspace.yaml); pnpm add itself can refuse to install a version published within that window, in which case this workflow run fails cleanly and the bump is left for Dependabot own next daily scan to pick up once the window has passed -- a neutral fallback, not a regression, since that scan would have handled it anyway.
3+
# Triggered the moment a sibling ExaDev package this repo depends on publishes a new version -- the publishing repo own ci.yml sends this repository_dispatch event right after semantic-release completes, instead of waiting for Dependabot own daily scheduled scan to notice. Bumps the named dependency, opens a PR, and requests auto-merge. The branch push and the PR-open call both authenticate via a freshly-minted GitHub App installation token, not the default GITHUB_TOKEN -- GITHUB_TOKEN-authenticated actions (a push OR opening a PR) do not cascade into further workflow runs, so a GITHUB_TOKEN-created PR would never trigger this repo own ci.yml pull_request checks at all, leaving nothing for auto-merge to wait on and letting GitHub treat the PR as already mergeable the instant it opens. Even with the App token making that cascade happen for real, there is a second, narrower race: GitHub can take a few seconds to actually register ci.yml own check-runs against the new PR, and calling gh pr merge --auto before any check has registered gets rejected with "Pull request is in clean status" -- confirmed happening in production even after the App-token fix landed. The wait step below polls for ci.yml own Test check-run to actually appear before requesting auto-merge, closing that race. This workflow never pushes directly to main -- the PR still only merges once this repo own CI genuinely passes on it. Note: every repo in this family also enforces a minimumReleaseAge pnpm supply-chain gate (see pnpm-workspace.yaml); pnpm add itself can refuse to install a version published within that window, in which case this workflow run fails cleanly and the bump is left for Dependabot own next daily scan to pick up once the window has passed -- a neutral fallback, not a regression, since that scan would have handled it anyway.
44

55
on:
66
repository_dispatch:
@@ -60,6 +60,21 @@ jobs:
6060
git push origin "$branch"
6161
pr_url=$(gh pr create --title "build(deps): bump ${PACKAGE} to ${VERSION}" --body "Automatic dependency bump triggered instantly by the ${PACKAGE} release." --base main --head "$branch")
6262
echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT"
63+
echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
64+
- name: Wait for this repo own real CI to register on the PR
65+
if: steps.diff.outputs.changed == 'true'
66+
env:
67+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
68+
run: |
69+
for i in $(seq 1 30); do
70+
found=$(gh api "repos/${{ github.repository }}/commits/${{ steps.pr.outputs.head_sha }}/check-runs" --jq '[.check_runs[] | select(.name == "Test")] | length')
71+
if [ "$found" -gt 0 ]; then
72+
echo "ci.yml own Test check has registered after $((i * 3))s"
73+
exit 0
74+
fi
75+
sleep 3
76+
done
77+
echo "::warning::ci.yml own Test check never registered after 90s -- proceeding anyway, but auto-merge may reject the PR as already clean or merge it immediately" >&2
6378
- name: Enable auto-merge
6479
if: steps.diff.outputs.changed == 'true'
6580
env:

0 commit comments

Comments
 (0)