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
stream
undertopic
We only care about the following events:
gollum
issues
opened
closed
edited
transferred
labeled
unlabeled
issue_comment
created
edited
deleted
pull_request
opened
edited
closed
pull_request_review
submitted
pull_request_review_comment
created
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 URL
tohttpsTrigger.url
+?stream=stream_name&topic=topic_name
- Set
Content type
toapplication/json
- Set
Secret
to$GITHUB_WEBHOOK_SECRET
- Select events to trigger this webhook