Set up GitHub webhooks to trigger new builds of Kubernetes apps


With every push to a repo, trigger new builds on Red Hat OpenShift on IBM Cloud

In this tutorial, you learn how to set up a GitHub webhook to trigger a new build of a Kubernetes app every time a push is made on the GitHub repo. Examples in this tutorial use Red Hat OpenShift on IBM Cloud and the Node.js Application Modernization Source-to-Image Code Pattern for the application.

After completing this tutorial you will be able to accomplish the following tasks:

  • Deploy an application to an OpenShift cluster.
  • Set up a GitHub webhook for an application.
  • Verify that the webhook works.
  • View and modify the webhook.


To complete this tutorial you need to set up the following accounts:

  • A GitHub account
  • An IBM Cloud account
  • A Red Hat OpenShift cluster created on IBM Cloud

Estimated time

Completing this tutorial should take about 30 minutes.

1. Fork the repo

Begin by forking the node-s2i-openshift repo at

2. Set up the OpenShift project

After you create your OpenShift cluster on IBM Cloud, you see the following OpenShift dashboard:

OpenShift dashboard on IBM Cloud screen capture
  1. Click the Create Project button to add a new project, and give it a name, for example, health-webhook.
  2. Click Browse Catalog.
  3. Select Node.js.
  4. Click Next.
  5. Click Advanced Options.The GitHub URL used in this tutorial is, but you might want to use your GitHub URL by forking the repo. You need write permissions in the repo that you decide to use.The following screen capture shows an example:
  6. Scroll down to the bottom and click Create.After the project is created, OpenShift creates a GitHub webhook payload URL. You can click the button to copy the URL.It is in the following structure:<SECRET>/github Also note the <SECRET> portion of the URL. You need that value in a later step.Click the Overview tab and wait for the build to finish. After the build is finished, you see a route is created. You can click that link to see that the app is available. Now that the app is up and running, you set up the webhook.

3. Set up a webhook

  1. In your GitHub repo, go to Settings.
  2. Select Webhooks and then click Add webhook.
  3. Fill in the form with the payload URL and Secret from the previous section. For the content type, select application/json. Click Add webhook.

If you make any push in your repo, it kicks off a new build. The following example makes some minor UI updates and triggers the webhook. From the GitHub UI, you can see the recent deliveries that completed. The first one was when you set it up. The second one is the result of the latest commit with the UI changes.

Screen capture of webhook delivery in GitHub

4. Verify the new OpenShift build

Back on the OpenShift dashboard, from the left menu, click Builds > Builds.

You can see the last build is #2 and verify that the changes are there by clicking on the link to see the app. See the following example:

Screen capture of new OpenShift build

5. Retrieve the webhook

If you want to retrieve the webhook information, you can always go back to the build.

  1. Click on the build name.
  2. Click Configuration and copy the GitHub webhook URL.

6. Change the webhook

If you want to change the GitHub settings for build, click Actions > Edit.

You can change the GitHub repo settings from here. For example, you can change the context or branch to build from.

In the triggers section you can find the secret that is set up for the GitHub webhook, as shown in the following screen capture:

Screen capture of webhook secret


You have now successfully deployed an application to OpenShift using the Source-to-Image (S2I) toolkit, added a GitHub webhook to the application that triggers a new build of the application when a new push is made on the GitHub repo, and learned where to view and modify the webhook.

With Red Hat Openshift on IBM Cloud, you can try it out on your own environment. To get started, see the Red Hat Openshift on IBM Cloud documentation.

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x