{"modulePath":"github.com/c360studio/semstreams","version":"v1.0.0-beta.146","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githubwebhook\n\nPackage githubwebhook provides an HTTP input component that receives GitHub webhook events and publishes them to NATS JetStream.\n\n## Functions\n\n```go\nfunc CreateInput(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)\n```\nCreateInput is the factory function for creating GitHub webhook input components. It follows the standard component factory signature so that it can be registered with the component registry.\n\n```go\nfunc Register(registry *component.Registry) error\n```\nRegister registers the GitHub webhook input component with the supplied registry.\n\n```go\nfunc RegisterPayloads(reg *payloadregistry.Registry) error\n```\nRegisterPayloads registers github webhook payload types (IssueEvent, PREvent, ReviewEvent, CommentEvent) with the supplied registry. Called from payloadbuiltins.Register at process bootstrap.\n\n## Types\n\n```go\ntype CommentEvent struct {\n\tWebhookEvent\n\tComment CommentPayload `json:\"comment\"`\n}\n```\nCommentEvent represents a GitHub \"issue\\_comment\" webhook event.\n\n```go\ntype CommentPayload struct {\n\t// Body is the comment text.\n\tBody string `json:\"body\"`\n\n\t// Author is the GitHub login of the comment author.\n\tAuthor string `json:\"author\"`\n}\n```\nCommentPayload contains the fields extracted from a GitHub issue comment.\n\n```go\ntype Config struct {\n\t// HTTPPort is the port the webhook HTTP server listens on.\n\tHTTPPort int `json:\"http_port\" schema:\"type:int,description:HTTP port for webhook receiver,default:8090,category:basic\"`\n\n\t// Path is the URL path that receives GitHub webhook POST requests.\n\tPath string `json:\"path\" schema:\"type:string,description:Webhook endpoint path,default:/github/webhook,category:basic\"`\n\n\t// WebhookSecretEnv is the name of the environment variable that holds\n\t// the HMAC secret used to validate X-Hub-Signature-256 signatures.\n\t// When empty, signature validation is skipped (not recommended for production).\n\tWebhookSecretEnv string `json:\"webhook_secret_env\" schema:\"type:string,description:Environment variable name for GitHub webhook HMAC secret,category:security\"`\n\n\t// RepoAllowlist restricts processing to specific repositories in\n\t// \"owner/repo\" format. An empty slice accepts events from all repositories.\n\tRepoAllowlist []string `json:\"repo_allowlist\" schema:\"type:array,description:Repositories to process (owner/repo format),category:basic\"`\n\n\t// EventFilter restricts which GitHub event types are accepted.\n\t// Valid values: issues, pull_request, pull_request_review, issue_comment.\n\t// An empty slice falls back to the package defaults.\n\tEventFilter []string `json:\"event_filter\" schema:\"type:array,description:GitHub event types to accept (issues;pull_request;pull_request_review;issue_comment),category:basic\"`\n\n\t// Ports configures the output NATS subjects for each event category.\n\tPorts *component.PortConfig `json:\"ports,omitempty\" schema:\"type:ports,description:Port configuration,category:basic\"`\n}\n```\nConfig holds configuration for the GitHub webhook input component.\n\n```go\nfunc DefaultConfig() Config\n```\nDefaultConfig returns a Config populated with sensible defaults.\n\n```go\ntype Input struct {\n\t// contains filtered or unexported fields\n}\n```\nInput implements the GitHub webhook HTTP receiver component.\n\n```go\nfunc NewInput(name string, natsClient *natsclient.Client, cfg Config, logger *slog.Logger) (*Input, error)\n```\nNewInput creates a validated Input from the supplied configuration and NATS client.\n\n```go\nfunc (i *Input) ConfigSchema() component.ConfigSchema\n```\nConfigSchema returns the configuration schema.\n\n```go\nfunc (i *Input) DataFlow() component.FlowMetrics\n```\nDataFlow returns current throughput metrics.\n\n```go\nfunc (i *Input) Health() component.HealthStatus\n```\nHealth returns the current health status.\n\n```go\nfunc (i *Input) Initialize() error\n```\nInitialize validates the configuration and pre-loads the webhook HMAC secret from the environment so that secret retrieval failures surface early.\n\n```go\nfunc (i *Input) InputPorts() []component.Port\n```\nInputPorts returns the input ports. The HTTP listener is the entry point, represented as a NetworkPort.\n\n```go\nfunc (i *Input) Meta() component.Metadata\n```\nMeta returns component metadata.\n\n```go\nfunc (i *Input) OutputPorts() []component.Port\n```\nOutputPorts returns the four JetStream output ports, one per event category.\n\n```go\nfunc (i *Input) Start(ctx context.Context) error\n```\nStart launches the HTTP server and begins accepting webhook deliveries.\n\n```go\nfunc (i *Input) Stop(timeout time.Duration) error\n```\nStop performs a graceful HTTP server shutdown within the supplied timeout.\n\n```go\ntype IssueEvent struct {\n\tWebhookEvent\n\tIssue IssuePayload `json:\"issue\"`\n}\n```\nIssueEvent represents a GitHub \"issues\" webhook event.\n\n```go\ntype IssuePayload struct {\n\t// Number is the repository-scoped issue number.\n\tNumber int `json:\"number\"`\n\n\t// Title is the issue title.\n\tTitle string `json:\"title\"`\n\n\t// Body is the issue body text (may be empty).\n\tBody string `json:\"body\"`\n\n\t// State is the issue state: \"open\" or \"closed\".\n\tState string `json:\"state\"`\n\n\t// Labels is the list of label names applied to the issue.\n\tLabels []string `json:\"labels\"`\n\n\t// Author is the GitHub login of the issue author.\n\tAuthor string `json:\"author\"`\n\n\t// HTMLURL is the canonical browser URL for the issue.\n\tHTMLURL string `json:\"html_url\"`\n}\n```\nIssuePayload contains the fields extracted from a GitHub issue object.\n\n```go\ntype PREvent struct {\n\tWebhookEvent\n\tPullRequest PRPayload `json:\"pull_request\"`\n}\n```\nPREvent represents a GitHub \"pull\\_request\" webhook event.\n\n```go\ntype PRPayload struct {\n\t// Number is the repository-scoped pull-request number.\n\tNumber int `json:\"number\"`\n\n\t// Title is the pull-request title.\n\tTitle string `json:\"title\"`\n\n\t// Body is the pull-request description (may be empty).\n\tBody string `json:\"body\"`\n\n\t// State is the PR state: \"open\", \"closed\", or \"merged\".\n\tState string `json:\"state\"`\n\n\t// Head is the name of the source branch.\n\tHead string `json:\"head\"`\n\n\t// Base is the name of the target branch.\n\tBase string `json:\"base\"`\n\n\t// HTMLURL is the canonical browser URL for the pull request.\n\tHTMLURL string `json:\"html_url\"`\n}\n```\nPRPayload contains the fields extracted from a GitHub pull-request object.\n\n```go\ntype Repository struct {\n\t// Owner is the organisation or user that owns the repository.\n\tOwner string `json:\"owner\"`\n\n\t// Name is the repository name without the owner prefix.\n\tName string `json:\"name\"`\n\n\t// FullName is the canonical \"owner/name\" identifier.\n\tFullName string `json:\"full_name\"`\n}\n```\nRepository holds the identifying fields of a GitHub repository.\n\n```go\ntype ReviewEvent struct {\n\tWebhookEvent\n\tReview      ReviewPayload `json:\"review\"`\n\tPullRequest PRPayload     `json:\"pull_request\"`\n}\n```\nReviewEvent represents a GitHub \"pull\\_request\\_review\" webhook event.\n\n```go\ntype ReviewPayload struct {\n\t// State is the review outcome: \"approved\", \"changes_requested\", or \"commented\".\n\tState string `json:\"state\"`\n\n\t// Body is the review summary comment (may be empty).\n\tBody string `json:\"body\"`\n}\n```\nReviewPayload contains the fields extracted from a GitHub pull-request review.\n\n```go\ntype WebhookEvent struct {\n\t// EventType is the value of the X-GitHub-Event header (e.g. \"issues\").\n\tEventType string `json:\"event_type\"`\n\n\t// Action is the fine-grained sub-action within the event type\n\t// (e.g. \"opened\", \"edited\", \"closed\").\n\tAction string `json:\"action\"`\n\n\t// Repository identifies the repository that generated the event.\n\tRepository Repository `json:\"repository\"`\n\n\t// Sender is the GitHub login of the user who triggered the event.\n\tSender string `json:\"sender\"`\n\n\t// ReceivedAt is the UTC timestamp at which this process received the event.\n\tReceivedAt time.Time `json:\"received_at\"`\n}\n```\nWebhookEvent is the common header present in every GitHub webhook event. Specific event types embed this struct and add their own domain-specific fields.\n\n","path":"github.com/c360studio/semstreams/input/github-webhook","name":"githubwebhook","synopsis":"Package githubwebhook provides an HTTP input component that receives GitHub webhook events and publishes them to NATS JetStream.","isRedistributable":true}
