Skip to content

Instantly share code, notes, and snippets.

@joshrp
Created January 31, 2015 14:36
Show Gist options
  • Save joshrp/89394d5012851accbb4c to your computer and use it in GitHub Desktop.
Save joshrp/89394d5012851accbb4c to your computer and use it in GitHub Desktop.
var githubhook = require('githubhook');
var github = githubhook({/* options */});
github.listen();
var mergeRegex = /^Merge pull request (#\d)+ from/;
github.on('*', function (event, repo, ref, data) {
console.log('Hook received for',repo);
var head = data.head_commit;
var pusher = data.pusher.name;
var matches = mergeRegex.exec(head.message);
if (matches === null) {
console.log('commit pushed', head.id.substr(0,8));
} else {
console.log('Pull request merged', matches[1]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment