Created
November 9, 2017 01:39
-
-
Save calebeby/27cdd0a416a73296155820051204ce74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const express = require('express') | |
const bodyParser = require('body-parser') | |
const nodemon = require('nodemon') | |
const {spawn} = require('child_process') | |
const pull = repo => new Promise((resolve, reject) => { | |
const gitPull = spawn('git', ['pull'], {cwd: `../${repo}`}) | |
gitPull.stdout.on('data', buf => console.log(buf.toString())) | |
gitPull.stderr.on('data', buf => console.log(buf.toString())) | |
gitPull.on('close', code => {code === 0 ? resolve() : reject(code)}) | |
}) | |
pull() | |
const core = nodemon({script: '../edward-core'}) | |
core.on('start', () => console.log('core has started')) | |
const ip = '67.169.223.206' | |
const port = 3000 | |
const app = express() | |
app.use(bodyParser.json()) | |
app.use(bodyParser.urlencoded({ | |
extended: true | |
})) | |
app.get('/', (req, res) => res.send('hello')) | |
app.post('/github-webhook', (req, res) => { | |
const repo = req.body.repository.name | |
pull(repo).then(() => core.emit('restart')) | |
res.send('hi github') | |
}) | |
app.listen(port, () => console.log(`http://${ip}:${port}`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment