nanaweb/github-listener-bundle

安装: 8

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分叉: 0

开放问题: 0

类型:symfony-bundle

v0.9.2 2019-07-09 14:57 UTC

This package is auto-updated.

Last update: 2024-09-10 02:43:29 UTC


README

如何安装

composer require nanaweb/github-listener-bundle:"~0.9"

然后,将 Nanaweb\GithubListenerBundle\NanawebGithubListenerBundle 添加到 AppKernel 中注册的包列表。无需配置。

如何使用

github webhook 事件 创建自己的 OperationRunner 类。OperationRunners 必须实现 Nanaweb\GithubListenerBundle\OperationRunner\OperationRunnerInterface 接口。

使用 nanaweb_github_listener.operation_runner 标签和 event 属性注册到 Symfony DI 容器中,如下所示

services:
    fake_operation_runner:
        class: App\GithubListener\OperationRunner\MyOperationRunner
        tags:
            - { name: nanaweb_github_listener.operation_runner, event: pull_request }

如何保护你的 webhook

使用 Nanaweb\GithubListenerBundle\Security\Guard\GithubWebhookAuthenticator 配置你的 guard 安全设置

# config/packages/security.yaml
security:
    # ...

    firewalls:
        # ...

        main:
            anonymous: ~
            logout: ~

            guard:
                authenticators:
                    - Nanaweb\GithubListenerBundle\Security\Guard\GithubWebhookAuthenticator

别忘了为 ReceiveController 添加 access_control 配置

# config/packages/security.yaml
security:
    # ...

    access_control:
        - { path: ^/nanaweb-github-listener/receive, roles: ROLE_GITHUB_WEBHOOK }