定制 kurozumi/github-webhook-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kurozumi/github-webhook-bundle

最新稳定版本:v1.0.2

Composer 安装命令:

composer require kurozumi/github-webhook-bundle

包简介

README 文档

README

Installation

composer require kurozumi/github-webhook-bundle

The configuration:

# .env

WEBHOOK_GITHUB_SECRET=1z9Y48dbgqxZi...

Webhook

Create a route:

framework:
    webhook:
        routing:
          github:
              service: webhook.request_parser.github
              secret: '%env(WEBHOOK_GITHUB_SECRET)%'

And a consume:

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
use Symfony\Component\RemoteEvent\RemoteEvent;

#[AsRemoteEventConsumer(name: 'github')]
final class GithubConsumer implements ConsumerInterface
{
    public function __construct(
        private EventDispatcherInterface $eventDispatcher,
    ) {
    }

    public function consume(RemoteEvent $event): void
    {
        $this->eventDispatcher->dispatch($event, $event->getName());
    }
}

How to use

use Symfony\Component\EventDispatcher\EventSubscriberInterface
use Symfony\Component\RemoteEvent\RemoteEvent;

class GithubWebhookListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            'pull_request' => 'onPullRequest',
        ]
    }
    
    public function onPullRequest(RemoteEvent $event): void
    {
        $payload = $event->getPayload();
        
        // do something
    }
}

Webhook events and payloads

https://docs.github.com/en/webhooks/webhook-events-and-payloads

统计信息

  • 总下载量: 89
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-07