Skip to content

Commit

Permalink
Accept Github webhook requests for the Github default branch
Browse files Browse the repository at this point in the history
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 OpenUserJS#1781
  • Loading branch information
phw committed Oct 16, 2021
1 parent 7a2f3d6 commit ab8646c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ab8646c

Please sign in to comment.