Created
October 3, 2016 07:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd cd:\pathToApp && git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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