Simple webhook handler on Google Cloud Functions sending custom messages to Zulip for GitHub events.
The official GitHub integration was too verbose for us.
zulipGitHubEvents does the following:
- Verify the request
- Create custom message based on the event or ignore it
- Send the message to
streamundertopic
We only care about the following events:
gollumissuesopenedclosededitedtransferredlabeledunlabeled
issue_commentcreatedediteddeleted
pull_requestopenededitedclosed
pull_request_reviewsubmitted
pull_request_review_commentcreated
Set environment variables:
GITHUB_WEBHOOK_SECRET: Secret to set when creating webhook on GitHubZULIP_BOT_EMAIL: Email of the Zulip botZULIP_BOT_API_KEY: API key of the Zulip botZULIP_REALM: Zulip URLPROJECT_ID: Google Cloud project ID
Deploy with gcloud:
gcloud functions deploy zulipGitHubEvents \
--trigger-http \
--allow-unauthenticated \
--runtime nodejs10 \
--memory 128MB \
--set-env-vars GITHUB_WEBHOOK_SECRET=$GITHUB_WEBHOOK_SECRET,ZULIP_BOT_EMAIL=$ZULIP_BOT_EMAIL,ZULIP_BOT_API_KEY=$ZULIP_BOT_API_KEY,ZULIP_REALM=$ZULIP_REALM \
--project $PROJECT_ID
Configure GitHub Webhook:
- Set
Payload URLtohttpsTrigger.url+?stream=stream_name&topic=topic_name - Set
Content typetoapplication/json - Set
Secretto$GITHUB_WEBHOOK_SECRET - Select events to trigger this webhook