Skip to content

Instantly share code, notes, and snippets.

@genecyber
Created May 13, 2015 18:40
Show Gist options
  • Save genecyber/e4eff83e0f931230ee91 to your computer and use it in GitHub Desktop.
Save genecyber/e4eff83e0f931230ee91 to your computer and use it in GitHub Desktop.
Poor man's node continuous integration server (nodejs, git, github)
/*
*
* Authored by Shannon code to be my poor man's continuous integration.
* I use forever on the server combined with nodemon to moniror files for changes and restart them
* I have a webhook set in github that hits the below server /deploy upon every push
*
*/
var express = require('express')
var basicAuth = require('http-auth')
var app = express()
var basic = basicAuth.basic({
realm: 'Admin Stuff'
}, function(username, password, callback) {
callback(username == 'admin' && password == 'password');
})
var authMiddleware = basicAuth.connect(basic)
app.post('/deploy',function(req,res){
doExecGit(function(error, stdout, stderr){
var retValue = {error: error || "", stdout: stdout || "" , stderr: stderr || "" }
console.log(retValue)
res.json(retValue)
})
})
app.listen(3009)
function doExecGit(cb){
var exec = require('child_process').exec,
child;
child = exec('git pull',
function (error, stdout, stderr) {
cb(error,stdout,stderr)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment