Skip to content

Commit

Permalink
detect push type implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
KoMinkyu committed Oct 13, 2016
1 parent cadc5a1 commit bd432f2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions alertserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,24 @@ def is_trusted_remote_addrs(remote_addr):
def tracking():
if request.method == 'POST':
data = request.get_json()

commit_author = data['actor']['username']
commit_hash = data['push']['changes'][0]['new']['target']['hash'][:7]
commit_url = data['push']['changes'][0]['new']['target']['links']['html']['href']
print('Webhook received! %s committed %s' % (commit_author, commit_hash))

is_branch_created = data['push']['changes'][0]['created']
is_branch_closed = data['push']['changes'][0]['closed']
if is_branch_created:
# TODO: Alert branch created.
print('Webhook received! %s created branch' % commit_author)
pass
elif is_branch_closed:
# TODO: Alert branch closed.
print('Webhook received! %s deleted branch' % commit_author)
else:
# TODO: Alert commits.
commit_hash = data['push']['changes'][0]['new']['target']['hash'][:7]
commit_url = data['push']['changes'][0]['new']['target']['links']['html']['href']
print('Webhook received! %s committed %s' % (commit_author, commit_hash))

return 'OK'


Expand Down

0 comments on commit bd432f2

Please sign in to comment.