Trigger conditional workflow when PR is merged
complete
Kim Yu Ng
I would like to trigger workflow or build when merging a PR from certain branch.
Since CircleCI has already supported conditional workflow and exposed git.branch in the pipeline, I believe this is doable with potential relative low effort if we have access to git.source_branch and git.event_type merge or maybe a simpler or higher-level API to accomplish this.
The current workaround provided by support seems to be hacky because it's cumbersome and it has to run workflow, trigger job and make an early exit in conditional step
The alternate workaround is using github action to make REST API to trigger the pipeline in CCI on closed pull_request against target branch with branch filtering of source branch.
B
Benedetta Dal Canton
complete
Hi, PM at CircleCI here.
I'm happy to announce that we have just introduced the ability to run pipelines on a broader range of GitHub events, including "Pull request merged".
Full announcement here: https://circleci.com/changelog/trigger-pipelines-on-github-pull-request-events/ , where you can find more information about how to set this up.
Pipelines can now be set up with explicit triggers, and configured to run on specific events.
The full range of options available is:
- All pushes
- Tag pushes
- Pushes to default branch
- PR opened or pushed to, default branch pushes, tag pushes
- PR merged
- PR marked ready for review
- *run-ci” label added to PR
Choosing this setting will make sure that your pipeline runs only when your PR is merged.
Configuring this new "GitHub App" triggers will also make two new pipeline values available:
- pipeline.event.name- which in the PR merged case will bepull_request
- pipeline.event.action- which will beclosed
For any questions, feedback or help setting this up, feel free to respond directly on here or email me directly at benedetta@circleci.com.
B
Benedetta Dal Canton
under review