def root()

in tekton/webhook/app.py [0:0]


def root():
    if request.method != 'POST':
        return '', 204

    # Fail if the sig does not match
    if not verify_github_signature(request):
        abort(401, 'Unauthorized')

    data = request.get_json()
    if not data:
        abort(404, 'JSON request not found')

    # Only accept 'push' events for now
    event = request.headers.get('X-GitHub-Event')
    if event not in config.ALLOWED_EVENTS:
        abort(404, 'GitHub Event not found')

    # Only accept known repos
    if data['repository']['full_name'] not in config.ALLOWED_REPOS:
        abort(404, 'Invalid repo')

    # return the data back to the Tekton event listener
    return data