🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

github scm: commitusingapi closes and reopens the pull request when the base branch has moved #11539

Done

Description

@mfairley

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

With a github scm that sets commitusingapi: true (and force left at its default, true), an open pull request is closed and a new one opened whenever the base branch has moved since the working branch was last updated.

What happens in one run:

  1. Checkout finds that the base branch's head is not an ancestor of the working branch and resets the working branch to the base (WARNING: branch "refs/heads/updatecli_main_<pipelineid>" diverged from "refs/heads/main", resetting it to "refs/heads/main").
  2. CreateCommit pushes that reset branch before it creates the commit (pkg/plugins/scms/github/scm.go, the IsForceReset() block: "Ensure that locally reset branch is pushed to remote branch before continuing with commit creation").
  3. The working branch on GitHub is now identical to the base branch. GitHub closes a pull request whose head has no commits ahead of its base, so the open pull request is closed within a few seconds.
  4. The commits are then created through the API, the github/pullrequest action finds no open pull request, and opens a new one.

The result is a new pull request number each time, with review comments and approvals left behind on the closed one. Without commitusingapi, the reset and the new commits reach GitHub in a single force push and the pull request stays open.

Expected Behavior

The existing pull request is updated in place, as it is when commits are made with git.

One way to get there: don't push the reset on its own. For example, create the new commits on top of the base branch's head without moving the working branch (on a temporary ref, or by building the commit chain first), and then force-update the working branch to the final commit in one step, so the branch never equals the base while a pull request is open.

Steps To Reproduce

  1. A manifest with a github scm using commitusingapi: true, a target that changes a file, and a github/pullrequest action. I authenticate as a GitHub App, in a repository that requires signed commits on every branch, which is why I use commitusingapi.
  2. Run updatecli pipeline apply. A pull request is opened.
  3. Push any unrelated commit to the base branch.
  4. Run updatecli pipeline apply again.
  5. The first pull request is closed (0 commits, 0 changed files) and a second one is opened with the same changes.
scms:
  default:
    kind: github
    spec:
      owner: <owner>
      repository: <repository>
      branch: main
      commitusingapi: true

actions:
  pull-request:
    kind: github/pullrequest
    scmid: default

Setting force: false on the scm looks like a workaround, since it skips the reset, but the working branch is then never brought up to date with the base.

Environment

- OS: Ubuntu 24.04 (GitHub Actions, ubuntu-latest)
- updatecli: v0.123.0 (the same code is on main as of v0.125.0)

Activity

  1. added a commit that references this issue on Dec 2, 2026
    5f43f1c
  2. moved this from Todo to Done in updateclion Dec 3, 2026
  3. added a commit that references this issue on Dec 3, 2026
    2e2b154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions