Commit d4483bdc authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

Support GitHub

parent d91c4f8a
emily-*.log
emily.cfg
......@@ -2,7 +2,7 @@
Emily Project Charter
=======================
:Authors:
* **Andrew Wilcox**, *project evangelist*
* **A. Wilcox**, *project evangelist*
* **Elizabeth Myers**, *open-source evangelist*
* **Horst Burkhardt**, *experience evangelist*
:Organization:
......@@ -12,7 +12,7 @@
:Status:
Draft
:Copyright:
© 2015 Wilcox Technologies LLC. NCSA open source licence.
© 2015-2017 Wilcox Technologies LLC. NCSA open source licence.
.. NOTE:: This document contains information about a forthcoming product from
Wilcox Technologies. The information contained within may not reflect
......
import asyncio
from emily.core import push_event
from emily.protocols.http import http_handle, HTTPProtocol
class GitHub:
""" Processes information from GitHub Web Hooks. """
PROTOCOLS = (HTTPProtocol,)
def __init__(self):
http_handle.add(self.http_handle)
@asyncio.coroutine
def http_handle(self, request):
if 'X-GitHub-Event' not in request.headers:
return False
json = yield from request.json()
if request.headers['X-GitHub-Event'] != 'push':
return False # we only do push right now
push_info = {}
push_info['user'] = {'name': json['pusher']['name'],
'email': json['pusher']['email']}
push_info['branch'] = json['ref'].split('/')[-1]
push_info['commits'] = []
for commit in json['commits']:
push_info['commits'].append({'id': commit['id'][:8],
'url': commit['url'],
'msg': commit['message'],
'author': commit['author']['name']})
project = request.match_info.get('grp', 'default') + '/' + \
request.match_info.get('project')
yield from push_event.call_async(project, push_info)
return True
from emily.inp.gitlab import GitLab
from emily.inp.github import GitHub
from emily.out.irc import IRC
......@@ -6,6 +7,7 @@ import emily.core
emily.core.register_in(GitLab)
emily.core.register_in(GitHub)
emily.core.register_out(IRC)
emily.core.run()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment