gulp-git-webhook
v0.1.0-alpha
Published
A Git(hub) webhook callback server to fetch new code (poor man CI)
Downloads
3
Readme
gulp-git-webhook
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 name | Description | Default | Type |
| ------------- | ------------- | ---------| -----|
| secret | A secret key pass to encrypt data between github and your server | '' | String |
| path | The path where the web hook call to your server | /webhook
| String |
| port | The port number where this callback server running on | 8081 | Integer |
| branch | The branch where you will trigger action when received event from github | refs/heads/master
| String |
| cmd | The command to execute when callback happens | git pull origin master --no-edit
| String |
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.