Trigger job on push on commit which is in a PR via if condition #26356
-
I seem to be unable to locate in the documentation where I can trigger a job with the following conditions only:
Which means that pushes on branches that are not currently in a PR would not trigger the job. How would one write such a workflow yaml file? I would like this to happen via the if: condition. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hi @basickarl, welcome to the GitHub Support Community! I believe you should be able to do this without needing to use the Events that trigger workflows - GitHub Docs
Or is there a specific reason you need to use the |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the welcoming :slight_smile:. I do wish to specifically do this via an if condition. I wish to do the following:
Basically I do not wish to deploy the application if it’s a normal push. Something like this:
|
Beta Was this translation helpful? Give feedback.
-
Awesome, thanks for the context! So in this case you should be able to look at the
You could also specifically only listen for pushes to the pull request too:
You can see the syntax for constructing these statements here: docs.github.comContext and expression syntax for GitHub Actions - GitHub Docs |
Beta Was this translation helpful? Give feedback.
-
Ah I see! I did try the following:
But it doesn’t seem to want to trigger a workflow now I am force pushing from branch km/auth0 (the workflow file is in that branch). |
Beta Was this translation helpful? Give feedback.
-
I solved the issue. It was that the PR had a merge conflict with the master branch. I resolved it and now the pull_request event is triggering correctly. Thanks @thomasshaped for your code, it also helped! |
Beta Was this translation helpful? Give feedback.
Awesome, thanks for the context! So in this case you should be able to look at the
event_name
item inside thegithub
context object.You could also specifically only listen for pushes to the pull request too:
You can see the syntax for constructing these statements here:
docs.github.com
Context and expression syntax for GitHub Actions - GitHub Docs