diff --git a/index.js b/index.js index e2b98da..e061d8c 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ import express from 'express' import expressWs from 'express-ws' +import { exec } from 'child_process' const app = express() const wsInstance = expressWs(app) @@ -47,4 +48,13 @@ app.ws('/webrtc/:channel', (ws, req) => { }) }) +// WEBHOOK 处理 GitHub 事件 +app.post('/webhook', (req, res) => { + console.log('WEBHOOK:', req.body) + return exec('git pull;npm i', (err, stdout, stderr) => { + if (err) return res.status(500).json({ error: err }) + return res.json({ stdout, stderr }) + }) +}) + app.listen(4096, () => console.log('Server started on port 4096'))