Documentation
¶
Overview ¶
Package webhooks provides GitHub webhook event parsing and signature validation. Supports pull_request, team, and membership event types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MembershipEvent ¶
type MembershipEvent struct {
Action string `json:"action"`
Scope string `json:"scope"`
Member *github.User `json:"member"`
Team *github.Team `json:"team"`
Organization *github.Organization `json:"organization"`
Sender *github.User `json:"sender"`
Installation *github.Installation `json:"installation"`
}
MembershipEvent represents a GitHub membership webhook payload.
func ParseMembershipEvent ¶
func ParseMembershipEvent(payload []byte) (*MembershipEvent, error)
ParseMembershipEvent unmarshals and validates a membership webhook.
func (*MembershipEvent) GetInstallationID ¶
func (e *MembershipEvent) GetInstallationID() int64
GetInstallationID returns the GitHub App installation ID.
func (*MembershipEvent) GetSenderLogin ¶
func (e *MembershipEvent) GetSenderLogin() string
GetSenderLogin returns the username of the user who triggered the event.
func (*MembershipEvent) GetSenderType ¶
func (e *MembershipEvent) GetSenderType() string
GetSenderType returns the sender's type (User or Bot).
func (*MembershipEvent) GetTeamSlug ¶
func (e *MembershipEvent) GetTeamSlug() string
GetTeamSlug returns the team's URL-friendly identifier.
func (*MembershipEvent) IsTeamScope ¶
func (e *MembershipEvent) IsTeamScope() bool
IsTeamScope returns true if the membership event is for a team.
type PullRequestEvent ¶
type PullRequestEvent struct {
Action string `json:"action"`
Number int `json:"number"`
PullRequest *github.PullRequest `json:"pull_request"`
Repository *github.Repository `json:"repository"`
Sender *github.User `json:"sender"`
Installation *github.Installation `json:"installation"`
}
PullRequestEvent represents a GitHub pull_request webhook payload.
func ParsePullRequestEvent ¶
func ParsePullRequestEvent(payload []byte) (*PullRequestEvent, error)
ParsePullRequestEvent unmarshals and validates a pull_request webhook. returns error if required fields are missing.
func (*PullRequestEvent) GetBaseBranch ¶
func (e *PullRequestEvent) GetBaseBranch() string
GetBaseBranch returns the target branch name.
func (*PullRequestEvent) GetInstallationID ¶
func (e *PullRequestEvent) GetInstallationID() int64
GetInstallationID returns the GitHub App installation ID.
func (*PullRequestEvent) GetRepoFullName ¶
func (e *PullRequestEvent) GetRepoFullName() string
GetRepoFullName returns the repository in owner/name format.
func (*PullRequestEvent) GetRepoName ¶
func (e *PullRequestEvent) GetRepoName() string
GetRepoName returns the repository name without owner.
func (*PullRequestEvent) GetRepoOwner ¶
func (e *PullRequestEvent) GetRepoOwner() string
GetRepoOwner returns the repository owner login.
func (*PullRequestEvent) IsMerged ¶
func (e *PullRequestEvent) IsMerged() bool
IsMerged returns true if the PR was closed via merge.
type TeamChangeDetail ¶
type TeamChangeDetail struct {
From string `json:"from"`
}
TeamChangeDetail contains the previous value before a change.
type TeamChanges ¶
type TeamChanges struct {
Name *TeamChangeDetail `json:"name,omitempty"`
Description *TeamChangeDetail `json:"description,omitempty"`
Privacy *TeamChangeDetail `json:"privacy,omitempty"`
Repository *TeamChangeDetail `json:"repository,omitempty"`
}
TeamChanges contains details about what changed in a team event.
type TeamEvent ¶
type TeamEvent struct {
Action string `json:"action"`
Team *github.Team `json:"team"`
Changes *TeamChanges `json:"changes,omitempty"`
Repository *github.Repository `json:"repository,omitempty"`
Organization *github.Organization `json:"organization"`
Sender *github.User `json:"sender"`
Installation *github.Installation `json:"installation"`
}
TeamEvent represents a GitHub team webhook payload.
func ParseTeamEvent ¶
ParseTeamEvent unmarshals and validates a team webhook.
func (*TeamEvent) GetInstallationID ¶
GetInstallationID returns the GitHub App installation ID.
func (*TeamEvent) GetSenderLogin ¶
GetSenderLogin returns the username of the user who triggered the event.
func (*TeamEvent) GetSenderType ¶
GetSenderType returns the sender's type (User or Bot).
func (*TeamEvent) GetTeamSlug ¶
GetTeamSlug returns the team's URL-friendly identifier.