-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c p r bot clobbers commits to PR when run as cron job #845
Comments
Hi @jamesp This is expected behaviour by the action. When a workflow executes the action to create or update a PR, fundamental to the design of the action is that the result of those two paths should not be different. Rebasing the PR branch and adding new commits is the best way to maintain that consistency. I have experimented in the past with trying to keep the full commit history each time the PR branch is updated, but it's more trouble than it's worth. In my experience, the only time I've need to make changes to an automated PR is when the automated change has caused CI to break and I want to make a small fix before merging. In this scenario the PR is merged as soon as the fix is made, so there is no opportunity for it to be clobbered. (Incidentally, I think that solutions like dependabot work similarly. If a new version of a dependency is available, dependabot closes the existing PR (clobbering any fix you might have made) and raises a new PR for the new version). Here are some suggestions:
|
Thanks @peter-evans for the detailed response and confirmation this is expected behaviour. I think the best thing to do for now will be for us to adjust our workflow to not leave uncommitted changes on that PR. I was thinking about whether it might be possible for the action to abort if it detects that there have been additional pushes to the branch it wants to update. Looking at the code here (I think this is the right place!) create-pull-request/src/create-or-update-branch.ts Lines 200 to 215 in 9825ae6
I don't think it's possible to, in the most general terms, be sure if the branch has been updated by someone else other than the bot since the last run of the action. However, for our specific use case I will experiment with adding an additional step to the workflow to check: This should prevent us from clobbering commits when we're too slow merging them! |
This is a good idea. 👍 This is the first time I've seen an issue about this, but if it becomes a common problem with many users I might consider adding some kind of |
A simple first pass attempted in the I'll update you if we have unforeseen issues with it. If you do have thoughts on how a robust |
c p r bot clobbers commits to PR when run as cron job
Developer pushes to the create-pull-request branch are being clobbered by create-pull-request running as a cron job.
We have a GHA workflow that updates python dependencies and saves them as a lockfile that is then turned into a PR by create-pull-request. The workflow runs once a week on a Saturday and pushes to branch
auto-update-lockfiles
. Commits that we push to the same branch are clobbered the following Saturday by the bot.I assume this is because CPR, when run as a cron job, is using master:HEAD as the base for the starting point. There may be an easy and obvious way around this, advice would be welcome. I think I want something like this perhaps, where
base
is theauto-update-lockfiles
branch if it exists, ormaster
if not. Is this possible?Steps to reproduce
See the actions workflow here:
https://github.com/SciTools/iris/blob/master/.github/workflows/refresh-lockfiles.yml
And resulting PR here:
SciTools/iris#4137
Note that the PR 4139 that was merged into this branch has been clobbered by the force push from the bot a few days later.
The text was updated successfully, but these errors were encountered: