webhook 自动pull

This commit is contained in:
2023-09-28 16:06:38 +08:00
parent 400d12725b
commit 1e68d79ecd
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import express from 'express' import express from 'express'
import expressWs from 'express-ws' import expressWs from 'express-ws'
import { exec } from 'child_process'
const app = express() const app = express()
const wsInstance = expressWs(app) 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')) app.listen(4096, () => console.log('Server started on port 4096'))