HOW TO ADD WEBHOOK IN GITHUB?
WHAT IS WEBHOOK?
There are many cases where an event happening in one system need to be informed to another system to trigger some related other events/actions in the second system. Webhookis a web callback or HTTP push API, which will provide information and data about an event to other applications.
For example: Whenever new code gets committed (event) to a code repository (first system), you may want to setup a Webhook in the repository to run and alert the build and deployment tool (second system) to redeploy the application.
Webhooks help in application integrations. Apps can subscribe to certain events in other systems and will get informed when such events happen in the subscribed system. In the above example, Build and Deployment Tool has subscribed for code commit events in the Code Repository System using Webhook.
ADDING A GIT WEBHOOK
Step 1: Login & Select a Repository
Login to Github and navigate to your code repository.WordPress repository is selected as an example below.
Step 2: Open settings
Click on the settings tab, on the right top side of the screen to open the settings page.
Step 3: Open WebhooksManagement Screen
From the left side menu, click and select Webhooks option.
Step 4: Add a new Webhook
Click on Add Webhookbutton on the top right side of the Webhook screen
Step 5: Edit/Add Webhook information
Add the following information in the Add Webhook screen
- a. Payload URL: Webhook URL here>
- b. Content Type: application/json or form-urlencoded> based on your requirement
- c. Secret:
- d. Events to trigger: push event or use the option let me select>
- e. Once the above information is entered, click on the green Add Webhookbutton.
Note: If you want to select individual events to trigger, use the following option.
This will enable Github to send a POST request with details subscribed to the URL specified in the above settings. The payload will contain information like, sender, action/event, repository, organization, etc.
Now you have successfully completed setting up a Webhook for your Github repository.
Interested in reading similar articles? Please follow us on LinkedIn.
About The Author
Dr. Anil Kumar
VP Engineering, CLOUD CONTROL
Founder | Vice President | CTO | Architect | Consultant | Mentor | Advisor | Faculty
Solution Architect and IT Consultant with more than 25 years of IT Experience. Served various roles with both national and international institutions. Expertise in working with both legacy and advanced technology stacks and business domains.