Unable to trigger CircleCI on pull request in Github

Hello,

I’m unable to trigger CircleCI status check for merge requests on my master branch in Github.
Strangely enough, when I initially did a setup on CircleCI with Github, everything was fine, the pipeline was properly getting invoked on every pull request events and showing the status checks, but then I noticed that the pipeline was also running after merging to master branch, which is a waste of compute resources, so then I decided to do something about it.
After changing some settings on the CircleCI UI, I ended up with this issue.

In some of the circleci discussions suggested to enable the Only build pull requests, but for some reason I don’t have it, even though it seems that I’m using the Github OAuth app integration with url https://app.circleci.com/pipelines/circleci/....

Any help would be much appreciated!

Edit: I have also tried by setting up custom webhook, but for some reason it uses the master branch config.yml file (e.g uses the fallback branch).

To clarify, your desired end state is that the pipeline gets triggered only on:

  • Pushes to the feature branch before a PR is open
  • Pushes to the default branch (including the push that gets auto-generated when you merge a PR)

You do not want the pipeline to run when a push happens to a branch that has an open pull request.

Is that accurate?

Not exactly,

What I would like is:

  • pipeline is triggered in push to feature branches, only when it’s used in PR (opened/synchronized/closed)
  • pipeline is NOT triggered in push to the default branch (the pipeline already ran before at the PR state, hence there is no need to run it on the same code again)

In Circle, the default branch always runs workflows by default, even when “only build pull requests” is on.

However, you can use branch filters to avoid this; something like:

workflows:
  version: 2
  ci_checks:
    jobs:
      - job1:
          filters:
            branches:
              ignore:
                - main
      - job2

Note that if you’re doing branch and filters on some jobs in the same workflow, you’ll need to make sure to include both branches and tags on all filters in that workflow.

You can use a YAML anchor if you want to repeat the same set of filters on multiple workflows

branch_filter: &branch_filter
  filters:
    branches:
      ignore:
        - main
        # just an example of another ignore pattern
        - /renovate\/.*/
# [...]
workflows:
  version: 2
  ci_checks:
    jobs:
      - job1:
          <<: *branch_filter
      - job2:
          <<: *branch_filter
      # this one has no filter
      - job3

@IliyanKostov9 got it, thanks for clarifying. and thanks @wyardley. Let us know if the answer Will gave isn’t sufficient?

Additionally, this is something that we’re looking at making a bit more intuitive to set up. You can see an example of what that interface might look like here in Benedetta’s comment: Canny

Let me know if you have any feedback on that approach as well.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.