webhook 自动pull
This commit is contained in:
parent
400d12725b
commit
1e68d79ecd
10
index.js
10
index.js
@ -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'))
|
||||||
|
Loading…
Reference in New Issue
Block a user