GitHub Webhooks
webhook-server/
contains the implementation of the GitHub webhook server portion of this project. The purpose of this server is to listen for events triggered by certain events of interest on GitHub resources.
Validating GitHub Webhook Deliveries
TODO
Local Development with GitHub Webhooks
In order to test webhook-server
locally, it is necessary to use a webhook proxy URL to forward webhooks from GitHub to your computer. Instructions for how to do this are as follows:
- In your browser, nagivate to https://smee.io/ and click Start a new channel.
- Copy the full URL under Webhook Proxy URL.
- Install the corresponding
smee-client
package from npm as a dev dependency:npm i sme-client --save-dev
. - Start the
smee-client
as follows:smee --url <Paste Webhook Proxy URL here> --path <Path to endpoint that handles webhook(s)> --port <port webhook server is listening on>
. - Go to a repository of interest in the PHACDataHub Github organization, go to Settings --> Code and automation --> Webhooks --> Add new webhook and paste the Webhook Proxy URL from step 1. Choose
application/json
for the content type. You can also choose which repo events get forwarded, or select "sent me everything" to receive all events. - Start up the
webhook-server
. - Trigger an event on the GitHub repo that you registered the webhook with. If everything is set up correctly, you should receive a request to
webhook-server
wherereq.body
contains the JSON payload of the GitHub webhook event.