System Information
- Strapi Version: 4
- Operating System: Ubuntu 22.04
- Database: Postgres
- Node Version: 16.17.0
- NPM Version: 8.15.0
- Yarn Version: -
Im following these guides: Digital Ocean and Strapi
I can see the updates are delivered from GitHub, they have a 200. But I’m not seeing the updates pulled to the server.
Im using a digital ocean droplet running Ubuntu 22.04.
If I run the webhook.js file directly with node and then push an update from GitHub it asks me for my GitHub credentials. I’m not sure if this is why it’s failing when running as a service. Do you need to send the credentials if you have a secret set in the webhook?
Response:
root: node webhook.js
Username for 'https://github.com':
webhook.js:
var secret = '12345';
var repo = '~/project';
const http = require('http');
const crypto = require('crypto');
const exec = require('child_process').exec;
const PM2_CMD = 'cd ~ && pm2 startOrRestart ecosystem.config.js';
http
.createServer(function(req, res) {
req.on('data', function(chunk) {
let sig =
'sha1=' +
crypto
.createHmac('sha1', secret)
.update(chunk.toString())
.digest('hex');
if (req.headers['x-hub-signature'] == sig) {
exec(`cd ${repo} && git pull && ${PM2_CMD}`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
}
});
res.end();
})
.listen(8080);