Skip to content

Commit

Permalink
Don't deploy on EVERY push to the repo 🙄 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdzwinel authored Oct 11, 2021
1 parent c7c1e54 commit 7c6701d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ app.post('/git', (req, res) => {
const hmac = crypto.createHmac('sha1', process.env.SECRET);
const sig = 'sha1=' + hmac.update(JSON.stringify(req.body)).digest('hex');

// don't deploy if push was to a branch other than main
if (req.body.ref !== 'refs/heads/main') {
return res.sendStatus(204);
}

if (req.headers['x-github-event'] === 'push' && crypto.timingSafeEqual(Buffer.from(sig, 'utf8'), Buffer.from(req.headers['x-hub-signature'], 'utf8'))) {
try {
fs.chmodSync('git.sh', '777'); /* Fix no perms after updating */
Expand Down

0 comments on commit 7c6701d

Please sign in to comment.