diff --git a/db/blockly_unix_database.db b/db/blockly_unix_database.db index f68ba3f..0cb96db 100644 Binary files a/db/blockly_unix_database.db and b/db/blockly_unix_database.db differ diff --git a/server.js b/server.js index 5966df8..57d1687 100644 --- a/server.js +++ b/server.js @@ -3,6 +3,7 @@ if (process.env.NODE_ENV !== 'production') { } const fs = require('fs'); // Importing libraries installed with npm +const { exec } = require('child_process'); const https = require('https'); const express = require('express'); const app = express(); @@ -63,6 +64,25 @@ app.use((req, res, next) => { next(); }); +app.post('/github-webhook', (req, res) => { + const githubSignature = req.headers['x-hub-signature-256']; + if (req.body.ref === 'refs/heads/main') { + exec('cd /blockly && git pull origin main', (err, stdout, stderr) => { + if (err) { + console.error(`Error executing git pull: ${stderr}`); + return res.sendStatus(500); + } + console.log(`Git pull output: ${stdout}`); + return res.sendStatus(200); + }); + } else { + res.sendStatus(200); + } +}); + +app.listen(4000, () => { + console.log('Listening for GitHub Webhooks on port 4000'); +}); // Middleware to add auth token function addAuthToken(req, res, next) { if (req.isAuthenticated()) {