From 330512b8c1082e2174ea5802eb02d2e71608ab1a Mon Sep 17 00:00:00 2001 From: mhkeller Date: Mon, 10 Nov 2014 12:31:47 -0500 Subject: [PATCH] acknowledge webhook creation ping --- lib/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/index.js b/lib/index.js index 1c84390..51d92fb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,6 +18,12 @@ module.exports = function (ref, action) { if (typeof payload.payload != 'undefined') { payload = JSON.parse(payload.payload); } + // GitHub send an initial ping on webhook creation, detect it by looking for `hook_id` + // Send a 200 response and stop further execution of this script. + if (typeof payload.hook_id == 'number') { + res.send(200, 'OK'); + return false; + } if (typeof payload.ref != 'string') { throw new Error('Invalid ref'); }