-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e9798c
commit 8efc8a2
Showing
5 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
node_modules | ||
credentials.js |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Created by matt on 4/10/15. | ||
*/ | ||
|
||
var githubApi = require('node-github'); | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var gitlog = require('../lib/gitlog'); | ||
|
||
var githubInstance = new githubApi({ | ||
version: '3.0.0' | ||
}); | ||
|
||
router.get('/ci/hook/update', function(req, res) { | ||
githubInstance.repos.getCommits({ | ||
user: "MatthaeusHarris", | ||
repo: "packagetracker" | ||
}, function(err, data) { | ||
if (err) { | ||
return res.render('500', err); | ||
} | ||
|
||
if (data[0].sha !== gitlog.log[0].hash) { | ||
// We need to update | ||
child_process.exec('git pull', function(err, stdout, stderr) { | ||
if (err) { | ||
return res.render('500', [err, stdout, stderr].join('\n')); | ||
} | ||
child_process.exec('npm install', function(err, stdout, stderr) { | ||
if (err) { | ||
return res.render('500', [err, stdout, stderr].join('\n')) | ||
} | ||
process.nextTick(function() { | ||
console.log("Process exiting to restart after CI chain trigger"); | ||
process.exit(0); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
res.json({'status': 'ok'}); | ||
} | ||
}); | ||
}); | ||
|
||
module.exports = router; |