Build all the pull request created against any branch.

So the thing is we want to verify if the PR that is merged to a target branch does not break the build.

So we want to run a actions job to build all PR that are created against any branch on our repo

Example 1 : 

master <---- BRANCH_1.       

we need to merge this BRANCH_1 with master and run our build steps before we can merge the PR created against it.

Example2 : 

BRANCH_DEV  <-------- BRANCH_XX

We also need to merge this BRANCH_XX to BRANCH_DEV and run our build steps before we can merge the PR.

My current workflow file is 

on:
  push:
  pull_request:
- "**"

But when i do this there are multiple build jobs triggered. Can someone help me understand this case and point me the right way to do this.

Hi @jeran7x ,

If your build jobs are triggered at the same time, please check if there are any status check required in branch protection rules on the target branch, please refer to official doc for more details.
Edit the source branch, it will trigger 2 workflows based on your workflow yaml, one is push event, the other is ‘pull_request: synchronize’ event. It’s recommended to check the github context of the workflow for confirmation.

PRinfo.png
If the jobs are triggered one by one, please check if there’s a commit submit with personal access token to source branch, it will trigger a new ‘pull_request:synchronize’ event workflow.

pull_request workflow will not help to merge the code automatically, if you check the github context, you will find the affected ref is ‘/refs/pull/prnumber/merge’ which is a temporary&fake merged branch.
Unless you click the ‘Merge pull request’ button in pull request, or have code commit push during workflow, the code will not be merged into target branch.

pull_request event doesn’t accept ‘- “**”’,only accept activity types, branches/tags, paths.

If you’d like to trigger PR workflow for any branch, you need to put the workflow yaml file in each source branch , code sample as below:

on: [pull_request]

Thanks.

1 Like

Hi @jeran7x , thanks for your kudos mark, is there any other query for this ticket?