-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpayload.js
36 lines (30 loc) · 1.21 KB
/
payload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const winston = require('./utils/winston');
let express = require('express');
let bodyParser = require('body-parser');
const res = require("express");
let app = express();
let exec = require('child_process').exec;
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.post('/payload', function (req, res) {
//verify that the payload is a push from the correct repo
//verify repository.name == 'wackcoon-device' or repository.full_name = 'DanielEgan/wackcoon-device'
winston.info(req.body.pusher.name + ' just pushed to ' + req.body.repository.name);
winston.warn('pulling code from GitHub...');
exec('git -C ~/Repos/Keystone reset --hard', execCallback);
exec('git -C ~/Repos/Keystone clean -df', execCallback);
exec('git -C ~/Repos/Keystone pull -f', execCallback);
exec('npm -C ~/Repos/Keystone install --production', execCallback);
exec('tsc', execCallback);
});
app.get('/payload', function (req, res) {
res.sendStatus(200);
console.log('get /payload');
});
app.listen(9000, function () {
winston.info('listening on port 9000')
});
function execCallback(err, stdout, stderr) {
if(stdout) winston.info(stdout);
if(stderr) winston.info(stderr);
}