implement webhook

This commit is contained in:
waltem01 2022-05-16 16:01:40 +02:00
parent acd04b8b2e
commit c8770a904b
2 changed files with 14 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
DuckRevamp/*
server/node_modules/*
server/node_modules/*
gitUpdate.sh

View File

@ -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);