egg-github-webhook

0.1.0-beta.4 • Public • Published

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

option | intro | type | default | | -|-|-|- path | Path of Payload URL | string | | secret | secret | string | | event | event object | object | object | |

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

Readme

Keywords

none

Package Sidebar

Install

npm i egg-github-webhook

Weekly Downloads

4

Version

0.1.0-beta.4

License

MIT

Unpacked Size

8.67 kB

Total Files

7

Last publish

Collaborators

  • chiaweilee