0.1.0-beta.4 • Published 5 years ago

egg-github-webhook v0.1.0-beta.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

egg-github-webhook · GitHub license npm version npm downloads PRs Welcome

🥚Egg plugin for processing GitHub Webhooks.

Installation

npm install egg-github-webhook

BeforeUse

Content type must be application/json, application/x-www-form-urlencoded won't work at present.

Usage

// 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.

Options

optionintrotypedefault
pathPath of Payload URLstring
secretsecretstring
eventevent objectobjectobject

Example

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