0

I am little confused here regarding PR being triggered against main branch?

All branches: (I know this will trigger pull request from any branch to any branch)

pipelines:
  pull-requests:
    '**':

Main branch: (Does this trigger pull request if created from feature/pe-1234 to main?)

pipelines:
  pull-requests:
    'main':

I want to know what happens if I mention only main. It is not clear in documentation or may be I didn't get it right

kittu
  • 6,662
  • 21
  • 91
  • 185

1 Answers1

2

The branch name / glob pattern in the pull-request pipeline definition is the source branch that should trigger that pipeline, not the target branch.

E.g. if you were following git-flow instead of github-flow, it would make sense to override the pipeline run by the PR from main to a release/whatever branch so that it simply passes, or does an integration test, but does not perform the usual tests, linting, coverage and whatnot.

pipelines:
  pull-requests:
    '**':  # triggers if no other specific pipeline was triggered
      - parallel:
          - step: *linting-step
          - step: *testing-step
    main:  # triggers from main to anywhere else
      - step:
          name: Pass
          script:
            - exit 0

If following github-flow, you will probably never make a PR from main to anywhere else, so you can safely skip this definition. Only if you wanted PRs from feature/AAA-NNNN branches to trigger a special pipeline besides the testing workflow, you can write an alternate pipeline like

pipelines:
  pull-requests:
    '**':  # triggers if no other specific pipeline was triggered
      - parallel:
          - step: *linting-step
          - step: *testing-step
    feature/*:  # triggers from feature/* to anywhere else (including to main)
      - parallel:
          - step: *linting-step
          - step: *testing-step
          - step: *maybe-hook-issue-tracker-step # ?

so that the simpler default '**' pipeline will not run. But it will run irrespective of the target branch, usually main but not necessarily.

N1ngu
  • 2,862
  • 17
  • 35