Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurozumi/github-webhook-bundle
Symfony GitHub Webhook Bundle
https://github.com/kurozumi/github-webhook-bundle
symfony symfony-bundle webhook
Last synced: 6 days ago
JSON representation
Symfony GitHub Webhook Bundle
- Host: GitHub
- URL: https://github.com/kurozumi/github-webhook-bundle
- Owner: kurozumi
- Created: 2024-10-07T00:39:55.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-09T01:29:31.000Z (about 1 month ago)
- Last Synced: 2024-11-13T10:15:24.892Z (6 days ago)
- Topics: symfony, symfony-bundle, webhook
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GitHub Webhook Bundle
## Installation
```shell
composer require kurozumi/github-webhook-bundle
```
The configuration:```env
# .envWEBHOOK_GITHUB_SECRET=1z9Y48dbgqxZi...
```## Webhook
Create a route:
```yaml
framework:
webhook:
routing:
github:
service: webhook.request_parser.github
secret: '%env(WEBHOOK_GITHUB_SECRET)%'
```And a consume:
```php
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
```php
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