Documentation
¶
Overview ¶
Package ghook is a small GitHub webhook receiver that maps pull-request lifecycle events to pgbranch branches (branch-per-PR): opened/reopened → ensure branch pr-<number> exists, synchronize → ensure (and optionally reset), closed → destroy. It talks to branchd through internal/apiclient and, when a GitHub token is configured, posts a one-time connect-info comment on the PR.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
WebhookSecret string // HMAC key for X-Hub-Signature-256 (required)
Source string // pgbranch source to branch from (required)
TTLSeconds int // branch TTL passed on create (0 = no TTL)
ResetOnPush bool // synchronize resets the branch when true
Repos []string // "owner/name" allow-list; empty allows all
ProxyHost string // host[:port] of the pgbranch proxy, for comments
}
Config is the static service configuration (see cmd/pgbranch-github for the GHOOK_* environment mapping).
type EnvConfig ¶
type EnvConfig struct {
Config
Listen string // GHOOK_LISTEN, default :8080
PGBranchServer string // GHOOK_PGBRANCH_SERVER (required)
PGBranchToken string // GHOOK_PGBRANCH_TOKEN
GitHubToken string // GHOOK_GITHUB_TOKEN (empty = no PR comments)
GitHubAPI string // GHOOK_GITHUB_API, default https://api.github.com
}
EnvConfig is the full GHOOK_* environment configuration for the pgbranch-github binary: the service Config plus wiring (listen address, pgbranch server, GitHub credentials).
type GitHub ¶
type GitHub struct {
BaseURL string // e.g. https://api.github.com (overridable for tests)
Token string
HTTP *http.Client
}
GitHub is a minimal REST client for the one thing this service does on GitHub: a single connect-info comment per pull request. No SDK dependency.
func (*GitHub) EnsureComment ¶
EnsureComment posts body as an issue comment on repo#number unless a comment carrying the pgbranch marker already exists. Only the first page (100 comments) is checked — at worst a busy PR gets a duplicate comment.