How to create a webhook in Gitlab to update a mirror repository in Github?

11

I would like to create a webhook in Gitlab to update a mirror repository in Github whenever there is a push . I looked up this demo page , but I did not quite understand how to do it.

My version of Gitlab is 6.5. Here is the configuration page:

In URL, should I put the GitHub repository that you would like to update? Or would it be the JSON file with the modifications generated by the push? It's hard to find documentation on how to do it.

    
asked by anonymous 19.02.2014 / 13:41

1 answer

6

Understanding Web Hooks

Web Hook is a method of receiving notifications of events occurring in web applications. When something happens in an application that supports Web Hooks, it makes a request for the configured URL by sending details of what happened.

This technique allows you to make application integrations with others or even extend the functionality of the application in a totally decoupled way, without having to modify the application, inject some kind of code or script, etc.

So this will not send the repository directly to GitHub or any other site. It is up to you to build an application that listens to the events and take the desired action, in case, clone the repository.

Checking which event to use

The current documentation shows you what events are generated and what content the configured URL will receive.

For example, the first case is when someone updates the repository by making a push . The configured URL will receive an HTTP request with the header (% header) X-Gitlab-Event with value Push Hook . The request body will contain details about the changes, such as the user who made the push and which commits were sent.

Implementing your application

At the end of the documentation there is an example of how to implement an application that listens to events. You should do something like that.

It can be in any language with any framework, but you will be responsible for the system that listens for events at the specified URL.

Upon receiving a request from a push event, your application should then clone the source repository (GitLab) and make the push on the target (GitHub).

    
08.09.2015 / 09:41