-
Look up the GitHub payload schema for the target event at https://docs.github.com/en/webhooks/webhook-events-and-payloads#<event_name>. Note which top-level keys carry the entity (e.g. pull_request, issue, release) and which carry action, html_url, title/name.
Verify: you know the exact key names before writing any $Message['...'] access.
-
Add the case block inside the switch ($EventType) block in web/github.php, immediately before default: (line ~265):
case 'your_event':
$Entity = $Message['your_event'];
$Action = $Message['action'] ?? '';
$Url = $Entity['html_url'] ?? '';
$Title = $Entity['title'] ?? $Entity['name'] ?? '';
$ChatMsg = "\u{1F514} [{$User}](https://github.com/{$User}) **{$Action}** "
. "[{$Title}]({$Url}) "
. "in [{$RepositoryName}](https://github.com/{$RepositoryName}).";
if (!empty($Entity['body'])) {
$ChatMsg .= "\n\n> " . substr($Entity['body'], 0, 500)
. (strlen($Entity['body']) > 500 ? "\u2026" : "");
}
$Msg['text'] = $ChatMsg;
SendToChat('notifications', $Msg, $useRC, $useTeams);
break;
This step uses $User, $RepositoryName, $Msg set before the switch.
-
Choose an emoji that fits the event. Reference from existing cases:
- Push / release:
📦
- Issue / bug:
🐛
- Pull request:
🔀
- Wiki (gollum):
📝
- CI check pass/fail:
✅ / ❌ / ⏳
- Generic/info:
ℹ️
-
Suppress noisy CI-style events by commenting out SendToChat and leaving $Msg['text'] set (matches check_suite/workflow_run pattern):
$Msg['text'] = $ChatMsg;
break;
-
Suppress for specific repos using the issues case pattern:
case 'your_event':
if (in_array($RepositoryName, ['owner/repo1', 'owner/repo2'])) {
$useTeams = false;
break;
}
-
Add a test fixture under tests/events/<event_name>/:
payload.json — raw GitHub webhook payload (copy from GitHub delivery logs or docs)
type.txt — event name only, e.g. your_event (no trailing newline needed; trim() is applied)
expected_text.txt — expected chat message text; run vendor/bin/phpunit tests/GithubMessageBuilderTest.php, capture actual output, write to file
-
Run quality checks to verify no syntax errors or style violations:
vendor/bin/phpstan analyse
vendor/bin/php-cs-fixer fix --dry-run
Fix any reported issues before committing.