Hotfix: Prevent webhooks from running on non-master/main branches

This commit is contained in:
rubenwardy
2021-03-07 14:47:27 +00:00
parent 4d2833de88
commit 9cb9f8a4f6
3 changed files with 13 additions and 3 deletions

View File

@@ -134,6 +134,10 @@ def webhook():
if event == "push":
ref = json["after"]
title = json["head_commit"]["message"].partition("\n")[0]
branch = json["ref"].replace("refs/heads/", "")
if branch not in [ "master", "main" ]:
return jsonify({ "success": False, "message": "Webhook ignored, as it's not on the master/main branch" })
elif event == "create" and json["ref_type"] == "tag":
ref = json["ref"]
title = ref