Skip to content

Instantly share code, notes, and snippets.

@mattneary
Created March 19, 2013 18:37
Show Gist options
  • Save mattneary/5198857 to your computer and use it in GitHub Desktop.
Save mattneary/5198857 to your computer and use it in GitHub Desktop.
Github Service Hook
var http = require('http');
var exec = require('child_process').exec;
var repo = "https://github.com/mattneary/Watterson-Dresses.git";
http.createServer(function(req, res) {
exec("rm -rf /home/ec2-user/sites/Watterson-Dresses", function(err, stdout, stderr) {
if( err ) {
res.writeHead(400);
res.end("error: "+JSON.stringify(err))
return;
}
exec("git clone "+repo, function(err, stdout, stderr) {
if( err ) {
res.writeHead(400);
res.end("error: "+JSON.stringify(err));
}
res.end(JSON.stringify([stdout, stderr]));
});
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment