-
Hello folks! The problematic (may be an issue/bug) : When I merge a PR from a branch to For you to get an overview of the git structure flow I’m using, here it is :
So far, PRs from But when it comes to PRs from And “push” events doesn’t seem to include any value I can use to detect whether it comes from Is every “pull_request” event followed by a “push” one? Because I’ve been trying the following and got two events, so two running workflow when PR staging to master :
Am I misunderstanding some points here, I’ve been searching documentation on this, but still no luck… The workflow file :
Does anyone have a clue on how I could solve this, in a reliable way? Thanks for reading! Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Just commenting briefly to say what you’re experiencing is expected. Since a PR merge is just a commit pushed to the target branch it will trigger I can’t think of an easy way to accomplish what you want but one more complicated possibility would be to make an API call to see if the push commit is seen in any recent pull requests. If it’s not then you know it’s a hotfix push. edit: clarified that your events don’t happen on open. Also, in the end you’ll probably want a workflow file similar to the one you tried where you list both |
Beta Was this translation helpful? Give feedback.
-
Hey @melink14! Thanks for the quick reply! You just made my day 🌞 I do now understand a bit more, is there any documentation about those behaviors? I already did search a lot, I may not be good at searching 🙃? Anyway, I’m just answering briefly, I’m testing my new CI/CD workflow and it seems to work as expected! TL;DR; I’m filtering hotfixes on the base branch’s name, and instead of a This basically did the trick:
I don’t like the fact of using the branch name in a Thanks again! Cheers! |
Beta Was this translation helpful? Give feedback.
-
Don’t feel bad, I think the documentation is a bit lacking when it comes to details and worked examples. (For example, how pull request branch targeting works is not explained in the event trigger docs) The only real place I could find this was a blurb in the GitHub action syntax docs where it talks about the syntax for adding branch restrictions to Workflow syntax for GitHub Actions - GitHub Docs//docs.github.com/en/actions/reference/workflow-syntax-for-github-actions (The part about the restrictions applying to the Essentially the core of action documentation will come from experience, this forum, and various GitHub repo issue threads. 😃 Good luck! Glad you found a short term fix; at first, I thought you were implying that you wanted to push hotfixes directly to the main branch with no PR which would be even harder! |
Beta Was this translation helpful? Give feedback.
Just commenting briefly to say what you’re experiencing is expected.
pull_request
event triggers when a PR event occurs targeting the branches specified in the workflow.push
event is triggered whenever a commit is pushed to the specified branches.Since a PR merge is just a commit pushed to the target branch it will trigger
push
events as you’ve seen.I can’t think of an easy way to accomplish what you want but one more complicated possibility would be to make an API call to see if the push commit is seen in any recent pull requests. If it’s not then you know it’s a hotfix push.
edit: clarified that your events don’t happen on open. Also, in the end you’ll probably want a workflow file s…