PR creation should not fail when there are no commits
Hi @thomaseizinger
I feel the PR creation should not report as failure when it has no commits to create a PR. Instead, it should succeed and report as a warning.
Currently it reports with below error and reports as failure in workflow. In automation, there could be scenarios where we can/cannot create a PR and i feel it would be nice if this github action be able to handle both.
Error: Validation Failed: {"resource":"PullRequest","code":"custom","message":"No commits between master and release-1.6"}
what do you think?
Thanks for opening this issue!
I think this may be solved more generally by something like https://github.com/actions/runner/issues/2347.
Not being able to create a PR is an error. I am struggling to see why this action should not fail as a result.
Maybe see if https://cli.github.com/manual/gh_pr_create solves your problem. The CLI comes pre-installed in all environments and you should be able to work around it failing by doing something like:
gh pr create ... || true
Thanks for your reply. continue-on-error set as true doesn't feel like a right option here because real errors are also skipped and marks the job as passed.
cli option also errors with exit code 1. so i have to add special logic to differentiate this error and other errors. cli doesn't come pre-installed in self-hosted runner, so we need to go extra step in setting all that up.
Just a quote from https://github.com/peter-evans/create-pull-request
How the action behaves:
If there are changes (i.e. a diff exists with the checked-out base branch), the changes will be pushed to a new branch and a pull request created. If there are no changes (i.e. no diff exists with the checked-out base branch), no pull request will be created and the action exits silently. If a pull request already exists it will be updated if necessary. Local changes in the Actions workspace, or changes on the base branch, can cause an update. If no update is required the action exits silently.
.. so other people also feel like it should exit silently when there are no commits.
Maybe it would be also helpful to extend the example with:
on:
push:
branches-ignore:
- master
https://github.com/peter-evans/create-pull-request seems to be much more popular than this action.
At the time I implemented mine, I did so because there was no alternative.
Is there something my action does that https://github.com/peter-evans/create-pull-request can't do? Because if not, I am going to deprecate this in favor of https://github.com/peter-evans/create-pull-request.
One less thing to maintain on my list :)
While I configured your action quite swiftly, I had problems to understand how to configure the PE pull request action. Now after a month playing with GitHub workflows I tried again and was able to use the PE pull request action.
So for me the advantage of your action was a better learning curve.
So Peter Evans confirmed that his action is not overlapping with this action:
For very simple use cases where you have an existing feature branch, this action is overkill. This action's primary use case is for situations where the feature branch does not exist yet.
I would recommend using the other
create-pull-requestaction you referenced, or just use github-script to call the GitHub API yourself.
Originally posted by @peter-evans in https://github.com/peter-evans/create-pull-request/issues/1243#issuecomment-1240161886
Okay that is interesting, thanks for posting that. Back when I created this, we just used regular calls to git to create the necessary branch / commits.
How are you creating your commits that you then PR with this action? Before I add an override for this error, I'd like to understand how you are ending up in this situation :)
Thanks!