Check in progress on github connection, this will not work.
This commit is contained in:
parent
7f89a5b7f0
commit
6b1fcefc26
2 changed files with 28 additions and 3 deletions
|
@ -1,13 +1,17 @@
|
|||
import logging
|
||||
import stripe
|
||||
import urlparse
|
||||
import json
|
||||
|
||||
from flask import request, make_response, Blueprint
|
||||
|
||||
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.email import send_invoice_email
|
||||
|
||||
from util.names import parse_repository_name
|
||||
from util.http import abort
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -36,3 +40,23 @@ def stripe_webhook():
|
|||
send_invoice_email(user.email, invoice_html)
|
||||
|
||||
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)
|
|
@ -23,3 +23,4 @@ redis
|
|||
hiredis
|
||||
git+https://github.com/dotcloud/docker-py.git
|
||||
loremipsum
|
||||
pygithub
|
Reference in a new issue