rvagg / github-webhook

A flexible web server for reacting GitHub Webhooks
MIT License
116 stars 24 forks source link

github-webhook

Build Status

NPM

A stand-alone GitHub Webhook end-point server.

Example

github-webhook \
  --port=9999 \
  --path=/webhook \
  --secret=mygithubsecret \
  --log=/var/log/webhook.log \
  --rule='push:ref == refs/heads/master && repository.name == myrepo:echo "yay!"'

You can also specify a --config <file> where file is a JSON file containing the same properties as are available as commandline options. The commandline will always override properties in the config file though.

{
  "port": 9999,
  "path": "/webhook",
  "secret": "mygithubsecret",
  "log": "/var/log/webhook.log",
  "rules": [{
    "event": "push",
    "match": "ref == \"refs/heads/master\" && repository.name == \"myrepo\"",
    "exec": "echo yay!"
  }]
}

Options

Rules

When reacting to valid GitHub Webhook payloads, you can specify any number of rules that will be matched and execute commands in a forked shell. Rules have three components:

You can either specify these rules in an array on the "rules" property in the config file, or as separate --rule commandline arguments where the components are separated by :, e.g.: --rule event:match:exec (you will generally want to quote the rule to prevent shell trickery).

Programatic usage

You can var server = require('github-webhook')(options) and you'll receive a http.Server object that has been prepared but not started.

More information

github-webhook is powered by github-webhook-handler, see that for more details.

License

github-webhook is Copyright (c) 2015 Rod Vagg and licensed under the MIT License. All rights not explicitly granted in the MIT License are reserved. See the included LICENSE.md file for more details.