0.1.0-alpha • Published 6 years ago

gulp-git-webhook v0.1.0-alpha

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

gulp-git-webhook NPM version Build Status Dependency Status

A Git(hub) webhook callback server to fetch new code (poor man CI)

This little tool is born out of real projects. Keep having to deploy and setup demo site etc. Why bother if you own the git account? You just need a new cert from github, add this to your project, and setup accordingly, and Viola, you get your own poor man CI :)

Installation

  $ npm install --save gulp-git-webhook

or

  $ yarn add gulp-git-webhook

Configuration && Usage

Create a js file (normally on your project root directory). Let's call it webhook.js.

const gitWebhook = require('gulp-git-webhook');
const config = {
  "secret": "your-github-webhook-secret",
  "path": "/webhook",
  "port": 8081,
  "branch": "refs/heads/master",
  "cmd": "git pull origin master --no-edit"
};
gitWebhook(config);

If your server is running Linux and support systemd; then you can use generator-nodex to generate a start up file


Then go to your github settings --> webhooks. Supply the configuration parameters:

Payload URL: The url where your server is running (let's use example.com) http://example.com:8081/webhook As you can see the port number 8081 and /webhook correspond the config file, so change it accordingly.

Content type: select application/json

Secret: generate your own secret phrase, again correspond the configuration file.

Which events would you like to trigger this webhook? Just the push event

Active: check this check box so you can see the log from github.

The cmd field is your config is the actual method to run. See table below for more details:

Full configuration properties

Property nameDescriptionDefaultType
secretA secret key pass to encrypt data between github and your server''String
pathThe path where the web hook call to your server/webhookString
portThe port number where this callback server running on8081Integer
branchThe branch where you will trigger action when received event from githubrefs/heads/masterString
cmdThe command to execute when callback happensgit pull origin master --no-editString

Debug option

If you want to know what is happening internally, you can pass NODE_ENV=debug. It will console lot out information.

  NODE_ENV=debug node ./webhook.js

License

MIT © NEWBRAN.CH

Power by generator-nodex.