def create_webhook(token, repo, url):
    client = _github_login(token)
    owner, repository = repo.split('/')
    repo = client.repository(owner, repository)
    hook = repo.create_hook(
        settings.GITHUB_HOOK_NAME,
        {
            "url": url, "content_type": "json",
            "secret": settings.GITHUB_HOOK_SECRET,
            "insecure_ssl": "0"
        },
        events=settings.GITHUB_HOOK_EVENTS,
        active=True
    )
    if not hook:
        raise CannotCreateHook("Cannot create hook for repo %s/%s" % (owner, repository))
    return hook.id
Create a webhook for the repo.
dataset/ETHPy150Open m-vdb/github-buildservice-boilerplate/buildservice/utils/github.py/create_webhook