Utilizing Web Hooks for Continuous Integration

What is a Web Hook?

When deploying code, you want to make sure it is automatically running through several relevant tests without you triggering them every single time. A webhook is like a notification for your CI/CD tests, that you have done something with your code. To set up a webhook, you first need to define rules that it follows:

  1. Choose Trigger Events: During the webhook setup process in GitHub, you specify which events will trigger the webhook. This could be a variety of actions, such as:
    • Pushes: Every time someone pushes code to the repository.
    • Pull Requests: When a new pull request is opened, closed, or merged.
    • Releases: When a new release is created.
    • Branch or Tag Creation: When a new branch or tag is created.
  2. Set the Payload URL: This is where you want GitHub to send the notification. The URL is provided by the service you want to notify (your CI/CD platform, for example).

  3. Configure Content Type: This determines how the data is formatted when sent to the receiver. JSON is a common format.

  4. Determine Security Options: If your receiving service requires it, you might also set up a secret token that GitHub will use to sign the data, adding a layer of security to ensure the data is only accepted if it’s verified as coming from GitHub.

Then, once you want to make a change, the following happens:

  1. You push code to GitHub - This is you updating your repository with new changes.
  2. GitHub sends a webhook - Because of the rule you set up, GitHub notifies your CI/CD tool that something happened (like a code push).
  3. CI/CD tool starts tests - The CI/CD tool, now informed by the webhook, starts running the tests or actions you’ve configured it to perform upon receiving such a notification.

References

Expand 1. “About Webhooks.” GitHub Docs, https://docs.github.com/en/webhooks/about-webhooks. Accessed 11 Apr. 2024.
2. “What Are Webhooks and How Do They Work.” What Are Webhooks And How Do They Work, 14 Aug. 2021, https://hookdeck.com/webhooks/guides/what-are-webhooks-how-they-work.
3. “What Is a Webhook? Webhooks for Beginners.” YouTube, YouTube, 30 Nov. 2021, https://www.youtube.com/watch?v=mrkQ5iLb4DM.
4. “What Is a Webhook?” Red Hat - We Make Open Source Technologies for the Enterprise, https://www.redhat.com/en/topics/automation/what-is-a-webhook. Accessed 11 Apr. 2024.