Check in progress on github connection, this will not work.

This commit is contained in:
yackob03 2014-02-11 13:53:44 -05:00
parent 7f89a5b7f0
commit 6b1fcefc26
2 changed files with 28 additions and 3 deletions

View file

@ -1,13 +1,17 @@
import logging import logging
import stripe import stripe
import urlparse
import json
from flask import request, make_response, Blueprint from flask import request, make_response, Blueprint
from data import model from data import model
from app import app from auth.auth import process_auth
from auth.permissions import ModifyRepositoryPermission
from util.invoice import renderInvoiceToHtml from util.invoice import renderInvoiceToHtml
from util.email import send_invoice_email from util.email import send_invoice_email
from util.names import parse_repository_name
from util.http import abort
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -36,3 +40,23 @@ def stripe_webhook():
send_invoice_email(user.email, invoice_html) send_invoice_email(user.email, invoice_html)
return make_response('Okay') return make_response('Okay')
@webhooks.route('/github/push/repository/<path:repository>', methods=['POST'])
@process_auth
@parse_repository_name
def github_push_webhook(namespace, repository):
# data = request.get_json()
permission = ModifyRepositoryPermission(namespace, repository)
if permission.can():
payload = json.loads(request.form['payload'])
ref = payload['ref']
repo = model.get_repository(namespace, repository)
token = model.create_access_token(repo, 'write')
host = urlparse.urlparse(request.url).netloc
tag = '%s/%s/%s:latest' % (host, repo.namespace, repo.name)
model.create_repository_build(repo, token, build_spec, tag)
abort(403)

View file

@ -22,4 +22,5 @@ logstash_formatter
redis redis
hiredis hiredis
git+https://github.com/dotcloud/docker-py.git git+https://github.com/dotcloud/docker-py.git
loremipsum loremipsum
pygithub