From 7c6701d440f2534f81af2f8e1a730bcf57c96a26 Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Mon, 11 Oct 2021 16:01:21 +0200 Subject: [PATCH] =?UTF-8?q?Don't=20deploy=20on=20EVERY=20push=20to=20the?= =?UTF-8?q?=20repo=20=F0=9F=99=84=20(#62)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server.js b/server.js index 6d58820..ab83df7 100644 --- a/server.js +++ b/server.js @@ -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 */