Repository navigation
Description
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:
- 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"). CreateCommitpushes that reset branch before it creates the commit (pkg/plugins/scms/github/scm.go, theIsForceReset()block: "Ensure that locally reset branch is pushed to remote branch before continuing with commit creation").- 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.
- The commits are then created through the API, the
github/pullrequestaction 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
- A manifest with a
githubscm usingcommitusingapi: true, a target that changes a file, and agithub/pullrequestaction. I authenticate as a GitHub App, in a repository that requires signed commits on every branch, which is why I usecommitusingapi. - Run
updatecli pipeline apply. A pull request is opened. - Push any unrelated commit to the base branch.
- Run
updatecli pipeline applyagain. - 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: defaultSetting 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)Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(github): keep the pull request open when commitusingapi resets th…
fix(github): keep the pull request open when commitusingapi resets th…