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'); }