From 10f7506292e449d50c2a3a1cb26d8cd803910b37 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 6 Feb 2019 01:18:57 +0100 Subject: [PATCH] [enh] handle create event --- server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server.py b/server.py index 082db56..359c6af 100644 --- a/server.py +++ b/server.py @@ -79,6 +79,23 @@ async def github(request): notify(f"[{repository}] @{user} comment on commit {commit_short_id}: {comment} {url}") + # https://developer.github.com/v3/activity/events/types/#createevent + elif hook_type == "create": + kind = request.json["ref_type"] + user = request.json["sender"]["login"] + repository = request.json["repository"]["name"] + + if kind == "repository": + f"@{user} created new repository {repository}: {url}" + elif kind == "branch": + branch = request.json["ref"] + f"[{repository}] @{user} created new branch {branch}" + elif kind == "tag": + tag = request.json["ref"] + f"[{repository}] @{user} created new tag {tag}" + else: + print(f"WARNING: unknown 'create' even kind: {kind}") + return text("ok")