Open In App
Related Articles

Google Cloud Platform – Designing an Issues Notification System using Cloud Run

Like Article
Save Article
Report issue

Problem Statement: Consider your run a Software company. And you have a huge client list who frequently use your software. You host your software on Github so that its users can send information regarding bugs in them. You being a lead developer in the team, how will you design a system that notifies the development team on Slack whenever an issue is submitted by a user on GitHub?

GitHub is one of the many services that provide event-driven Webhooks. This means is that if someone files an issue, Github will send a request to a URL specified by the developer. To ensure that if someone files an issue in GitHub, the developer team is notified and the issue isn’t lost in their inbox.

We can use Cloud Run to host the new Webhook target. This means developers won’t have to worry about servers, and they can use the language and framework that they are comfortable with.

The first thing you have to worry about is authorization. It would look somewhat like below:


@app.route("/" , methods = [ "POST" ])
def index():
  make_request = request
  signature = make_request.headers.get("X-Hub-Signature")
  data =
  assert verify_signature(signature, data)


A Webhook target is a public URL, and anyone with the URL could send anything to it. To ensure you are only processing valid requests, you can make use of a shared secret. You will need to create a secret key and put one copy in the GitHub configuration and store a copy securely with the Cloud Secret Manager. These secrets would look something like below depending upon your need:

$ SECRET = "$(python3 -c 'import secrets
$ echo - $SECRET | cloud beta secrets
create github-secret
--replication-policy = automatic

Every request from GitHub is signed, so you can use the secret to validate the signature and only process the valid requests. A generics signature verification function is given below, it may change depending upon your verification requirements:


def verify_signature(signature, data):
  expected = "sha1="
    secret = get_secret(PROJECT, SECRET, "1")
    hashed =, data, sha1)
    expected += hashed.hexdigest()
  except Exception as error:
  return hmac.compare_digest (signature)


Now development team will be able to securely receive events from GitHub, and a developer can use these events to send messages to Slack using the Slack API. A developer at this will write a function to send a message to the team’s Slack channel every time a valid request from GitHub is received. A sample function would look like below:


def slack_message( issue_title, issue_url):
  message = format_msg(issue_title, issue_url)
  Request = urllib.request.Request( SLACK_URL, data = message)
  Request.add_header("Content-Type", "application/json")


Your team will never miss another issue. To measure how long it takes the team to close an issue. You can add one more function to the Webhook to stream any issue events to BigQuery so it can easily create metrics around the team’s issue performance. The full Webhook target is now creating notifications, triggering an action, and streaming data into BigQuery.

Last Updated : 21 Dec, 2022
Like Article
Save Article
Share your thoughts in the comments
Similar Reads