🥚Egg plugin for processing GitHub Webhooks.
npm install egg-github-webhook
Content type must be application/json
, application/x-www-form-urlencoded
won't work at present.
// plugin.js
githubWebhook: {
enable: true,
package: 'egg-github-webhook',
}
// config.default.js
githubWebhook: {
path: '/',
secret: 'your-github-webhook-password',
event: {
// a js path
push: './scripts/githook.js',
// or a function
push: function (event) {
// do sth
},
}
}
tips: It is possiable to use YAML.
option | intro | type | default | | -|-|-|- path | Path of Payload URL | string | | secret | secret | string | | event | event object | object | object | |
event: {
push: function(event) {
if (event.payload) {
const { ref, commits } = event.payload;
if (ref === 'refs/heads/master') {
if (!commits.every(commit => commit.message !== 'build: release')) {
cmd.run('git pull');
}
}
}
};
}