-
Select Topic AreaBug BodyI have a (manual) workflow that automatically creates a pull request through the GitHub API (a variant of https://github.com/hrvey/combine-prs-workflow). Unfortunately, my other workflows with an Any idea what the problem could be? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hi Markus, It seems like the GitHub Actions is not being triggered because the pull request is created via the GitHub API. When a pull request is created this way, the However, when you do a force push on the created branch, it triggers the As a workaround, you might consider using a different event to trigger your workflow. For example, you can use the Here is an example of how you could set up your workflow file to be triggered by a
And then, you can create a repository dispatch event via the GitHub API like this:
I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Some guidelines have now been added here:
|
Beta Was this translation helpful? Give feedback.
-
In case someone at GitHub reads this, I think it would be great if the story for this was simplified! Let me tell a story. I had been procrastinating on automating creating pull requests in a repo based on certain events, because I thought it would be complicated. I finally got around to doing it, and boy was I amazed at how smooth it was! That the gh CLI tool is just available out of the box in GitHub Actions is incredibly useful. This is my workflow in essence: on:
whatever:
jobs:
my-cool-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
# do stuff, including git commit
# then, create the PR:
gh pr create --fill
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} I didn’t even need to fiddle with creating tokens or anything – the above Just Works out of the box! There’s just one little detail. Nothing much. Not a show stopper. Just that you can’t merge the automatically created pull request. 🙃 But who needs merging, right? 😉 The reason they can’t be merged is because of status checks not firing. Status checks set as Required in branch protection rules. Which are great, and GitHub is promoting them with this banner at the top of your repos without a branch protection rule: Now, I get why workflows using But have a look at this issue for a very popular action for creating pull requests: peter-evans/create-pull-request#48. At the time of writing, it has 246 issues or pull requests linking to it, from various open source projects documenting why they had trouble with workflows not running for pull requests created from GitHub Actions. And that’s not counting all private projects. I think this shows that there’s demand for a way to automate pull request creation without jumping through hoops. I mean, we’re so close already! Falling on the finishing line always hurts the most. Looking back at my short and sweet workflow, reading the recommendations on how to work around the problem didn’t feel super nice. It was exactly the things I dreaded when procrastinating on my automation. Making a PAT seems the simplest, but they expire every year, and I’d have to remember to update it. Making a GitHub App felt pretty complicated. You know what? I’m gonna go with the stupid workaround of manually closing and re-opening the pull request to trigger the checks. It means I have to wait for the checks to finish (instead of them being done once I see the PR), but it is what it is. I have one solution idea. The goal with the current limitations is to prevent recursion loops. Instead of disallowing workflows using My branch protection rules usually have just one single workflow as a required status check. If at least that worked, that would be a huge improvement. Thanks for reading! 💙 |
Beta Was this translation helpful? Give feedback.
Actually, I just found another discussion on this topic, which answers why no workflow is triggered: https://github.com/orgs/community/discussions/57484
The issue wasn't that I used the API but that I used it from a GitHub workflo…