Estimated time

1. Fork the repo

2. Set up the OpenShift project

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

Click the Create Project button to add a new project, and give it a name, for example, health-webhook.

Click Browse Catalog.

Select Node.js.

Click Next.

Click Advanced Options.

The GitHub URL used in this tutorial is https://github.com/moficodes/node-s2i-openshift/, 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:

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.

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

In your GitHub repo, go to Settings.

Select Webhooks and then click Add webhook.

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.

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:

5. Retrieve the webhook

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

Click on the build name.

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:

Summary

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.