]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add tag push support to webhooks
authorrubenwardy <rw@rubenwardy.com>
Sat, 25 Jan 2020 01:14:01 +0000 (01:14 +0000)
committerrubenwardy <rw@rubenwardy.com>
Sat, 25 Jan 2020 01:14:01 +0000 (01:14 +0000)
app/blueprints/github/__init__.py
app/blueprints/gitlab/__init__.py

index e3ce8d7aa3a6c5c089695fd909f5a41379c28102..8c6aaa82a1e3d66acc29b636b0080cdba79e5f72 100644 (file)
@@ -123,12 +123,15 @@ def webhook():
 
        event = request.headers.get("X-GitHub-Event")
        if event == "push":
-               title = json["head_commit"]["message"].partition("\n")[0]
                ref = json["after"]
+               title = json["head_commit"]["message"].partition("\n")[0]
+       elif event == "create" and json["ref_type"] == "tag":
+               ref = json["ref"]
+               title = ref
        elif event == "ping":
                return jsonify({ "success": True, "message": "Ping successful" })
        else:
-               return error(400, "Unsupported event. Only 'push' and 'ping' are supported.")
+               return error(400, "Unsupported event. Only 'push', `create:tag`, and 'ping' are supported.")
 
        #
        # Perform release
index daddc1ebe7175f68ed52d0a8fc1c4bb581e29414..45b4aa59cfb0d09a5655c3cac60ac1a47517750f 100644 (file)
@@ -54,8 +54,11 @@ def webhook():
        if event == "push":
                ref = json["after"]
                title = ref[:5]
+       elif event == "tag_push":
+               ref = json["ref"]
+               title = ref.replace("refs/tags/", "")
        else:
-               return error(400, "Unsupported event. Only 'push' is supported.")
+               return error(400, "Unsupported event. Only 'push' and 'tag_push' are supported.")
 
        #
        # Perform release