This script acts as a web hook for GitHub events, processes them, and returns messages which can be sent out to an IRC channel.
GitHub_WebHook.php
accepts, processes and validates an event,
it also can make sure that the event came from a GitHub server.
Functions in this class are:
Accepts an event, throws Exception
on error.
Returns true if a request came from GitHub's IP range, false otherwise.
Retuns true if HMAC hex digest of the payload matches GitHub's, false otherwise.
Returns event type. See https://developer.github.com/webhooks/#events for a list of events.
Returns decoded JSON payload as an object.
Returns full name of the repository for which an event was sent for.
GitHub_IRC.php
accepts input from previous script and outputs
a colored string which can be sent to IRC.
GitHub_IRC
constructor takes 3 paramaters (last one is optional).
All you need to do is pass data after parsing the message with GitHub_WebHook
like so: new GitHub_IRC( $Hook->GetEventType(), $Hook->GetPayload() );
URL shortener paramater takes a function, and that function should accept a single string argument containing an url. If your function fails to shorten an url or do anything with it, your function must return the original url back.
After calling the constructor, using this function will return a string which can be sent to an IRC server.
Throws GitHubNotImplementedException
when you pass an event that
is not parsed anyhow, and throws GitHubIgnoredEventException
for
fork
, watch
and status
events which are ignored by design.
Events [ref]
Event | Status | Notes |
---|---|---|
CommitCommentEvent | 👍 | |
CreateEvent | ❌ | |
DeleteEvent | 👍 | |
DeploymentEvent | ❌ | |
DeploymentStatusEvent | ❌ | |
ForkEvent | 💧 | Ignored by design |
GollumEvent | 👍 | |
InstallationEvent | ❌ | |
InstallationRepositoriesEvent | ❌ | |
IssueCommentEvent | 👍 | |
IssuesEvent | 👍 | assigned , unassigned , labeled , unlabeled events are ignored by design |
LabelEvent | ❌ | |
MarketplacePurchaseEvent | ❌ | |
MemberEvent | 👍 | edited events are ignored by design |
MembershipEvent | ❌ | |
MilestoneEvent | 👍 | edited events are ignored by design |
OrganizationEvent | ❌ | |
OrgBlockEvent | ❌ | |
PageBuildEvent | ❌ | |
PingEvent | 👍 | Not documented by GitHub, sent out when a new hook is created |
ProjectCardEvent | ❌ | |
ProjectColumnEvent | ❌ | |
ProjectEvent | 👍 | edited events are ignored by design |
PublicEvent | 👍 | |
PullRequestEvent | 👍 | synchronize , assigned , unassigned , labeled , unlabeled , review_requested , review_request_removed events are ignored by design |
PullRequestReviewEvent | 👍 | |
PullRequestReviewCommentEvent | 👍 | |
PushEvent | 👍 | Only distinct commits are counted and printed. Ignores branch deletions (use delete event instead) |
ReleaseEvent | 👍 | |
RepositoryEvent | 👍 | |
StatusEvent | 💧 | Ignored by design |
TeamEvent | ❌ | |
TeamAddEvent | ❌ | |
WatchEvent | 💧 | Ignored by design |
RepositoryVulnerabilityAlertEvent | 👍 |