From ab8646c96844e2e1c765f2a8aca3cca6b9188ae0 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Sat, 16 Oct 2021 17:23:12 +0200 Subject: [PATCH] Accept Github webhook requests for the Github default branch This allows the webhook to work independent of the name of the default branch on Github (which used to be master, but is now main and can be renamed by the repository owner). Fixes #1781 --- controllers/scriptStorage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/scriptStorage.js b/controllers/scriptStorage.js index 5d8607c1b..d0da00d62 100644 --- a/controllers/scriptStorage.js +++ b/controllers/scriptStorage.js @@ -2223,8 +2223,9 @@ exports.webhook = function (aReq, aRes) { // - // Only accept commits from the `master` branch - if (payload.ref !== 'refs/heads/master') { + // Only accept commits from the default branch + defaultBranch = `ref/heads/${payload.repository.default_branch}` + if (!(payload.ref === defaultBranch || payload.ref === 'refs/heads/master')) { aRes.status(403).send(); // Forbidden return; }