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

Asked

Viewed 1,778 times

11

I’d like to create a webhook in Gitlab to update a mirror repository in Github whenever there is one push. I consulted this one demo page, but I didn’t quite understand how to do.

My version of Gitlab is 6.5. Here is the setup page: inserir a descrição da imagem aqui

Under URL, should I put the Github repository you’d like to update? Or would it be the JSON file with the modifications generated by push? It is very difficult to find documentation on how to do.

  • 6

    Why do the downvotes?

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 requests the configured URL by sending details of what happened.

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

Therefore, this will not send the repository directly to Github or any other website. It is up to you to build an application that listens to events and takes the desired action, in case, clone the repository.

Checking which event to use

To current documentation shows 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 worthwhile Push Hook. The body of the request 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 similar.

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

Upon receiving an event-originated request push, your application should then clone the source repository (Gitlab) and do the push destination no (Github).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.