Sending Build Status Notification From Google Container Builder to Github

This basically an attempt to get a status events from Google Container Builder back to Github, since Google Container Builder don’t support build based on Pull Request, at least Not Yet. Back then, a friend of mine, Cakra Wardhana, told me if it’ll good if we can get the build status from Container Builder back to Github based on commit SHA. He then explained a little bit about Github API V3, specifically the Status Event. I’ve create a simple Container Builder to Slack before with also his help. We can use the fact that a Build resource was sent to Google PubSub each time Container Builder was triggered.

Based on that information, I’m using Google Cloud Function to get events from Google PubSub and sent the Status event back to Github.

const createStatusNotification = (build) => {
let message = {
state: getStatus(build),
target_url: build.logUrl,
description: build.statusDetail,
context: “continuous-integration/container-builder”
};
return message
}

To authenticate the request to Github API I’m using octonode, the authentication process are based on personal token.

References:

  1. Auto Assign Reviewers using Cloud Functions
  2. Sending Build Notifications
  3. Github API V3: Statuses
  4. Configuring Notifications for Third-Party Services
Like what you read? Give Irvi Aini a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.