Created
January 4, 2018 18:57
-
-
Save stevenvergenz/6eff72d3f6daf9a8a3f8646ef332df23 to your computer and use it in GitHub Desktop.
git hook deploy
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
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