Repository navigation
Description
This can trigger CI on the base commit and overwrite its commit status in external CI systems.
Summary
With signed-commits: true (the default), pushSignedCommits creates a new remote branch with git.createRef pointing at the base commit (e.g. main's HEAD), then adds the agent's commit(s) with GraphQL createCommitOnBranch (actions/setup/js/push_signed_commits.cjs ~L758–L783 @ v0.89.21).
This produces two push webhooks for one action. The first announces a new branch whose head is the base commit. External CI systems that build on branch pushes (Buildkite in our case) start a build for the base commit, then skip or cancel it as "intermediate" when the real commit arrives a second later. Commit statuses are keyed by SHA + context, not by branch, so that skipped or cancelled status replaces the base branch's real status in the GitHub UI. In our repo, main's HEAD goes from ✅ passed to ❌ "Build #N skipped" every time the workflow opens a PR.
Reproduction
- A workflow with
safe-outputs.create-pull-request(defaultsigned-commits: true) targetingmain. - A CI provider that builds every branch push, reports a commit status, and skips intermediate builds on non-default branches.
- Run the workflow so that it opens a PR.
gh api repos/<owner>/<repo>/commits/<main HEAD>/statuses: the newest status for the CI context iserror: Build #N skipped, created seconds after the workflow'screateRef, and it replaces main's real build result.
Example sequence on main HEAD 073df28:
09:40:25Z success | Build #16527 passed <- real main build at 073df28
09:45:30Z pending | Build #16531 scheduled <- bot branch created at 073df28 (same hash)
09:45:31Z error | Build #16531 skipped <- overwrites main's status
Expected
Creating a PR branch should never make a ref point at the base commit, so CI never sees a "new" branch at a commit that already belongs to the base branch. Even better if it never reports a meaningless intermediate commit.
Proposed fix
When the branch does not exist yet, create the first commit before the ref:
- Build the tree with
git.createTree(base_tree= base commit's tree) and create the commit withgit.createCommit(parent = base OID). With no custom author or signature, GitHub signs API-created commits made by an app orGITHUB_TOKEN. git.createRefat that commit's SHA.- Continue with
createCommitOnBranchfor any remaining commits, as today.
As an alternative, an opt-in setting could pre-create the ref at a placeholder commit, or let create-pull-request reuse an existing branch without recreate-ref deleting it (today handleRemoteBranchCollision renames, fails, or deletes and recreates the branch at the base SHA, so pre-creating the branch upstream of the safe-outputs job cannot work around this).
Environment
- gh-aw
v0.89.21(create-pull-request, defaults;allowed-branches: ["changelog-bot/*"]) - CI: Buildkite GitHub integration, with intermediate builds skipped or cancelled on non-default branches
Activity