def index()

in webhooks-with-cloud-run/Monolith/main.py [0:0]


def index():
    signature = request.headers.get("X-Hub-Signature", None)
    body = request.data

    # Only process data with a valid signature
    assert verify_signature(signature, body), "Unverified Signature"

    # Load the event as JSON for easier handling
    event = request.get_json(force=True)

    # Insert row into bigquery
    insert_row_into_bigquery(event)

    # Post new issues to Slack
    if event["action"] == "opened":
        issue_title = event["issue"]["title"]
        issue_url = event["issue"]["html_url"]
        send_issue_notification_to_slack(issue_title, issue_url)

        # Post response to Github
        create_issue_comment(event["issue"]["url"])

    print("Yay")

    sys.stdout.flush()
    return ("", 204)