Documentation
¶
Overview ¶
Package github implements push-to-deploy: a webhook endpoint that turns GitHub push events into builds, and GitHub App authentication for cloning private repos and posting commit statuses (spec F9, T-37).
Index ¶
Constants ¶
const ( StatusPending = "pending" StatusSuccess = "success" StatusFailure = "failure" )
CommitStatus states for SetCommitStatus.
Variables ¶
This section is empty.
Functions ¶
func SignPayload ¶
SignPayload returns the "sha256=<hex>" signature for a body (used by tests and the CLI setup helper).
Types ¶
type App ¶
type App struct {
ProjectID string
AppID string
Repo string // "owner/name"
InstallationID int64
WebhookSecret []byte // unsealed HMAC secret
BranchEnvironments map[string]string
}
App is the resolved GitHub configuration for a repository.
type Deduper ¶
Deduper records processed delivery ids (with a TTL) so redelivered webhooks are not built twice. Seen returns true if the id was already recorded.
type Deployer ¶
type Deployer interface {
DeployGit(ctx context.Context, app *App, envName, branch, sha, cloneURL, token string) (deploymentID string, err error)
}
Deployer creates a build + deployment for a pushed commit.
type GitHubApp ¶
type GitHubApp struct {
// contains filtered or unexported fields
}
GitHubApp authenticates as a GitHub App: it signs a short-lived JWT with the app private key, exchanges it for per-installation access tokens (cached until just before expiry), and posts commit statuses.
func NewGitHubApp ¶
NewGitHubApp builds an app authenticator from a PEM-encoded RSA private key.
func (*GitHubApp) InstallationToken ¶
InstallationToken returns a cached-or-fresh access token for an installation.
type Option ¶
type Option func(*GitHubApp)
Option configures a GitHubApp.
func WithBaseURL ¶
WithBaseURL overrides the GitHub API base (tests point it at httptest).
func WithHTTPClient ¶
WithHTTPClient overrides the HTTP client.
type TokenSource ¶
type TokenSource interface {
InstallationToken(ctx context.Context, installationID int64) (string, error)
}
TokenSource mints GitHub App installation access tokens for cloning.