implement webhook
This commit is contained in:
parent
acd04b8b2e
commit
c8770a904b
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
DuckRevamp/*
|
||||
server/node_modules/*
|
||||
server/node_modules/*
|
||||
gitUpdate.sh
|
|
@ -1,4 +1,3 @@
|
|||
// This comment tests the functionality of git webhooks
|
||||
// Start Date: 2021/10/11 15:00:00
|
||||
|
||||
const port = 3000;
|
||||
|
@ -22,6 +21,7 @@ const cSave = __dirname+'/count.save';
|
|||
const http = require('http');
|
||||
const express = require('express');
|
||||
const socketio = require('socket.io');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const app = express();
|
||||
const clientPath = __dirname+'/../client';
|
||||
|
@ -31,6 +31,17 @@ app.use(express.static(clientPath));
|
|||
const server = http.createServer(app);
|
||||
const io = socketio(server);
|
||||
|
||||
app.post('/receiveUpdate', (req, res) => {
|
||||
res.status(200).json({success:true});
|
||||
let updater = exec('sh ../gitUpdate.sh', (error, stdout, stderr) => {
|
||||
console.log(stdout);
|
||||
console.error(stderr);
|
||||
if (error !== null) {
|
||||
console.error(`exec error: ${error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(r => {
|
||||
setTimeout(r, ms);
|
||||
|
|
Loading…
Reference in New Issue
Block a user