Run GitLab Pipeline for Pull-Request on GitHub

Hi,

as we wan’t to switch from TravisCI to GitLabCI, I build a multistage pipeline to run our tests, create a build and finally start a deployment if everything works fine. Therefore the repo mirroring is running to stay synced with the original GitHub repo.

We need to use GitHub because all of our resources stored there and I can’t make the whole company switch because of the deployment of just one project.

So, is it possible to integrate that a Pipeline is triggered for a Pull-Request on GitHub?
Also the status of the pipeline should be transferred to check it before you are able to merge the PR on Github.

TravisCI handles PR’s very well, it creates a merge branch and run the tests on it right away.

Actually I handled to start a pipeline with adding a webhook to the Github-Pull-Request-Event wich calls a webhook trigger for a GitLab pipeline for the desired branch. But there wont be a necessary status check or branch merge now.

What is the best practice for this scenario without switching completely to GitLab?

I would appreciate help.
Thanks and best regards.

2 Likes

This is something that I am looking at as well.
I am looking to move away from Jenkins to GitLabCI, but need to figure out a way from GitLabCI triggering only on PR.

1 Like

Hello @cewald,

I want to overcome this limitation too.

Could you share how you configure your GitHub repo to have “a webhook trigger for a GitLab pipeline for the desired branch” ?

On my side, I opened a GitLab’s support request.

At first I builded a small Github-App via NodeJS which handles webhooks from Github when a pull-request is opened or updated and starts a Github status check (each build as a single check run).
In this small application I was able to check which branch should trigger a pipeline or not by simply whitelisting them.

When the NodeJS app triggered a pipeline in Gitlab, I added a variable with the Github’s pull request id, so I can pull the PR branch from Github instead the original one during the running pipeline – that is how I’am able to test the merged code of a Github PR.

I was using the Oktokit-Library of Github with ExpressJS to build the app – but I would definitly recommend using a library as Probot.


Meanwhile Gitlab released the feature to disable the static status check names for Github’s status checks. I decided not using the above app anymore so I don’t have to care about the infrastructure and code and simply run tests for each commit in each branch and not just for the integration- or master-branches and.

Thanks for your detailed answer.

@cewald,

If you don’t use your GitHub-App right now, how do you do ?
I’m not sure to understand how you use the “Static / dynamic status check names” feature. On my setup, I disabled it.

Issue opened on GitLab: https://gitlab.com/gitlab-org/gitlab-ee/issues/6775

1 Like

Thats right, I disabled it as well and then I added the status-check in the Github branch protection settings. Then, Github triggers a build for each commit pushed to the repository and if they fail the status check won’t be “green” and you won’t be able to merge this branch.