Support only: merge_requests for GitHub Pull Requests

Problem

We are using the full Gitlab integration functionality to run Gitlab CI against our our Github repository.

By default, Gitlab CI is starting a pipeline for all commits on all branches. We would like to only run builds against open Github Pull Requests.

  1. With "no extra config" in our .gitlab-ci.yaml, Gitlab is starting a pipeline for all commits. This does report correctly to open Github PRs, but overtaxes our workers, as they pointlessly build dozens of other pushed commits to branches with no PR.
  2. With only: [merge_requests], Gitlab builds nothing, as we aren't creating Merge Requests.

Can Gitlab be configured to interpret only: [merge_requests] as "pull requests" when pointed at a Github repository? Is there some other simple way of having Gitlab start pipelines again Github PRs, not all commits/branches?

Proposed solution(s)

  1. Support `only/except: merge_requests` for exter... (gitlab-foss#65139 - closed)
  2. Support `rules:if: $CI_PIPELINE_SOURCE == "external_pull_request_event" to only run CI for the branch of the PR. - This works today
Edited Jun 28, 2022 by James Heimbuck
Assignee Loading
Time tracking Loading