github

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 15 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 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.

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
}

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, deduped by job ID across polls; a job still queued past redispatchAfter is re-emitted.

func New

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

New authenticates as each AppAuth's installation and constructs a Poller. interval must be > 0; auths must be non-empty.

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