Skip to content

Instantly share code, notes, and snippets.

@stevenvergenz
Created January 4, 2018 18:57
Show Gist options
  • Save stevenvergenz/6eff72d3f6daf9a8a3f8646ef332df23 to your computer and use it in GitHub Desktop.
Save stevenvergenz/6eff72d3f6daf9a8a3f8646ef332df23 to your computer and use it in GitHub Desktop.
git hook deploy
var http = require('http');
var repo = require('simple-git')(__dirname);
var server = http.createServer(function(req,res){
repo.pull(function(err, data){
if(err){
console.log(err);
res.statusCode = 500;
res.end();
}
else if(data.summary.changes + data.summary.insertions + data.summary.deletions === 0){
console.log('Pull requested, no changes');
res.statusCode = 304;
res.end();
}
else {
console.log('Pull requested, updating');
res.statusCode = 200;
res.end();
}
});
});
server.listen(3142);
console.log('Listening on port 3142');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment