Is there a way to trigger a GitLab-CI build from GitHub?

I have several projects on GitHub, they’re there so anyone can use them if they’re useful. We have an internal GitLab instance. What I’d like to do is make CI run a deploy script when I push changes to a GitHub repo. So far I haven’t seen any way to do that. Is there something in CI that could receive what GitHub sends using their webhook?

Ultimately I can write a custom script to do this, but I’d prefer to have all my CI stuff in one place.

You need to have project in GitLab to use GitLab CI. GitLab CI is part of GitLab now and takes necessary information from GitLab database and repositories. If you have same project on GitHub and GItLab instance I can propose you setup code mirroring from GitHub to GitLab so when someone make a push to GitHub it trigger push to GitLab too. And push to GitLab will trigger GitLab CI build.

Yes. I was thinking of a small project with my deploy scripts in it. That project would have some http endpoint that GitHub could post to. Then I could automatically run my build scripts.

I can think of a couple other ways to do this, but I think they could get messy…

I could have the git origin be on gitlab, then add another one on github. Then I have to push to both origins.

I could run a cronjob that automatically asks github if the code should be updated.

I could buy GitLab EE and use mirroring. (If work could find that money…)

And so on. But for something as small as this, I’d really rather keep it simple. And if CI can receive webhooks from github, that would be pretty simple.

I’m asking here because I couldn’t find anything in the docs. I did find something about an api, if I remember correctly, but the docs were rather sparse. So I wondered if someone had figured out how to use the api to do what I just described. I kept the first first post short so that I wouldn’t limit answers in any way. Like when customers say “I want this, this, and this.” When they should be saying, “I want to do this. How should I do it?”

But for something as small as this, I’d really rather keep it simple

I don’t think you can keep it simple based on what you need to achieve. If I would be you I just setup cronjob or push to multiple remotes at same time. You can setup multiple URL to one remote in git and use command like

git push all master

1 Like

I just ran into this issue on another project today. Googled around and found my old topic… Heh. After some more searching, I went ahead and posted this new feature request: https://gitlab.com/gitlab-org/gitlab-ce/issues/38091

While pushing to more than one origin does work, it would be better if we had a more direct integration.