github

package
v0.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package github implements a polling Source backed by the GitHub Actions API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIURL added in v0.2.11

func APIURL(base string) string

APIURL returns the REST API root of the instance at base, without a trailing slash. GHES serves its API under /api/v3.

func AppInstallURL added in v0.2.11

func AppInstallURL(base, slug string) string

AppInstallURL returns the page that installs the App with slug. GHES serves App pages under /github-apps, github.com under /apps.

func InstallationID

func InstallationID(ctx context.Context, appID int64, key []byte, a AppAuth) (int64, error)

InstallationID resolves the App's installation for a's target (org or repo) via a JWT-only client. Shared by every source that authenticates as the App.

func ListInstallationRepos

func ListInstallationRepos(ctx context.Context, c *github.Client) ([]*github.Repository, error)

ListInstallationRepos paginates through all repos the App installation can access.

func NewAppClient

func NewAppClient(ctx context.Context, a AppAuth) (*github.Client, error)

NewAppClient returns a go-github client authenticated as the App installation for a's target (org or repo). The installation ID is discovered automatically.

func NewClient added in v0.2.11

func NewClient(hc *http.Client, base string) (*github.Client, error)

NewClient returns a go-github client over hc for the instance at base.

func WebURL added in v0.2.11

func WebURL(base string) string

WebURL returns the browser root of the instance at base.

Types

type AppAuth

type AppAuth struct {
	AppID          int64
	PrivateKeyPath string
	Org            string
	// Owner/Repo name a single repo target (personal-account or per-repo).
	Owner string
	Repo  string
	// Repos optionally restricts an org target's polling to these repo names;
	// empty polls all installation repos. Unused for repo targets.
	Repos []string
	// BaseURL names a GHES instance; empty means github.com.
	BaseURL string
}

AppAuth identifies a GitHub App installation. It is either org-scoped (Org set) or repo-scoped (Owner+Repo set, for personal-account repos that have no org-level runner pool). Exactly one form is populated.

func ParseScope

func ParseScope(scope string) AppAuth

ParseScope is Scope's inverse: a valid "owner/repo" → repo target, else org target. Kept beside Scope, built on the canonical grammar in domain.

func (AppAuth) Scope

func (a AppAuth) Scope() string

Scope returns the tenant scope this auth mints under: the org login, or "owner/repo" for a repo target. Matches domain.Job.Org.

type Poller

type Poller struct {
	// contains filtered or unexported fields
}

Poller polls every configured org's repos for queued workflow runs and emits each queued job as a domain.Job on every pass, from a fresh listing or from the run cache. A re-emission is what keeps a waiting job in the agent's queue; the agent and the control plane reject a repeat while a dispatch for the job is live.

func New

func New(ctx context.Context, auths []AppAuth, interval time.Duration, m *metrics.Agent) (*Poller, error)

New authenticates as each AppAuth's installation and constructs a Poller. interval must be > 0; auths must be non-empty. m receives the per-org API error and breaker series.

func (*Poller) RelistGap added in v0.2.13

func (p *Poller) RelistGap() time.Duration

RelistGap bounds how stale an emitted job's state can be: a run is re-listed at least this often, and its cached jobs are re-emitted until then.

func (*Poller) Subscribe

func (p *Poller) Subscribe(ctx context.Context) (<-chan domain.Job, error)

Subscribe begins polling and returns a channel that closes when ctx is done. The first poll happens immediately so callers don't wait an interval to see already-queued jobs at startup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL