Skip to content

Instantly share code, notes, and snippets.

@malkitsingh
Created October 3, 2016 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malkitsingh/fb96101a59a1b217f017fce396c091e4 to your computer and use it in GitHub Desktop.
Save malkitsingh/fb96101a59a1b217f017fce396c091e4 to your computer and use it in GitHub Desktop.
Gist for setting up webhook to pull from rep and run rebuild commands for us
/* Create a webhook in your GIT repo and put your IP-ADDRESS:1340
* select content-type : application/json
* do a npm install github-webhook-handler
* to start the server - node hook.js
*
*/
var http= require("http");
var exec = require('child_process').exec;
http.createServer(function(req, res) {
console.log('Inside create server')
//console.dir(req);
if (req.method == 'POST') {
console.log("POST");
var script_file = __dirname+'/mybat.bat';
console.log('File to call: ', script_file);
exec(script_file, function(error, stdout, stderr) {
console.log(stdout);
if(error != null) {
console.log('Error during the execution of redeploy: ' + stderr);
console.log('*******************************************************************************');
}
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('post received '+ stdout);
});
}
}).listen(1340);
cd cd:\pathToApp && git pull
{
"name": "express-auth",
"version": "1.0.0",
"private": true,
"description": "A basic express app with authentication",
"main": "server.js",
"author": "",
"license": "ISC",
"engines": {
"node": "6.3.0"
},
"dependencies": {
"github-webhook-handler": "^0.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment