internal

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package internal implements the workflow-plugin-github plugin, providing GitHub webhook handling and GitHub Actions workflow management.

Index

Constants

This section is empty.

Variables

View Source
var ErrEphemeralRunnerCapabilityUnsupported = errors.New("ephemeral runner capability unsupported")
View Source
var Version = "0.0.0"

Version is set at build time via -ldflags "-X github.com/GoCodeAlone/workflow-plugin-github/internal.Version=X.Y.Z"

Functions

func NewGitHubPlugin

func NewGitHubPlugin() sdk.PluginProvider

NewGitHubPlugin returns a new githubPlugin instance.

func NewGitHubRunnerProviderHTTPHandler added in v1.0.3

func NewGitHubRunnerProviderHTTPHandler(name string, raw map[string]any) (http.Handler, error)

Types

type AppTransport added in v1.0.2

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

AppTransport implements http.RoundTripper for GitHub App authentication, automatically refreshing the installation token as needed.

func NewAppTransport added in v1.0.2

func NewAppTransport(mod *githubAppModule) *AppTransport

NewAppTransport creates an http.RoundTripper that uses App installation tokens.

func (*AppTransport) RoundTrip added in v1.0.2

func (t *AppTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip injects the installation token into each request.

type CheckRun

type CheckRun struct {
	ID      int64  `json:"id"`
	HTMLURL string `json:"html_url"`
	Status  string `json:"status"`
}

CheckRun represents a GitHub Check Run response.

type CheckRunOutput

type CheckRunOutput struct {
	Title   string `json:"title"`
	Summary string `json:"summary"`
}

CheckRunOutput holds the title and summary for a check run.

type CreateCheckRunRequest

type CreateCheckRunRequest struct {
	Name       string          `json:"name"`
	HeadSHA    string          `json:"head_sha"`
	Status     string          `json:"status"`
	Conclusion string          `json:"conclusion,omitempty"`
	Output     *CheckRunOutput `json:"output,omitempty"`
}

CreateCheckRunRequest holds parameters for creating a GitHub Check Run.

type EphemeralRunnerJob added in v1.0.10

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

func NewEphemeralRunnerJob added in v1.0.10

func NewEphemeralRunnerJob(driver EphemeralRunnerJobDriver) *EphemeralRunnerJob

func (*EphemeralRunnerJob) Run added in v1.0.10

type EphemeralRunnerJobDriver added in v1.0.10

type EphemeralRunnerJobDriver interface {
	OrgRegistrationToken(ctx context.Context, organization string) (GitHubRunnerRegistrationToken, error)
	RunGitHubJob(ctx context.Context, mode EphemeralRunnerJobMode, spec EphemeralRunnerJobSpec, token GitHubRunnerRegistrationToken) (EphemeralRunnerJobResult, error)
	RemoveOrgRunner(ctx context.Context, organization string, runnerID int64) error
}

type EphemeralRunnerJobMode added in v1.0.10

type EphemeralRunnerJobMode string
const (
	EphemeralRunnerJobModeDispatchThenWait EphemeralRunnerJobMode = "dispatch_then_wait"
	EphemeralRunnerJobModeAttachToQueued   EphemeralRunnerJobMode = "attach_to_queued"
)

type EphemeralRunnerJobRequest added in v1.0.10

type EphemeralRunnerJobRequest struct {
	Mode                EphemeralRunnerJobMode `json:"mode"`
	Environment         string                 `json:"environment"`
	OS                  string                 `json:"os"`
	WorkerID            string                 `json:"worker_id"`
	TaskID              string                 `json:"task_id"`
	Organization        string                 `json:"organization"`
	Repository          string                 `json:"repository,omitempty"`
	Workflow            string                 `json:"workflow,omitempty"`
	Ref                 string                 `json:"ref,omitempty"`
	RunnerGroup         string                 `json:"runner_group,omitempty"`
	Timeout             time.Duration          `json:"-"`
	RequiredRuntimeCaps []string               `json:"required_runtime_caps,omitempty"`
	AdvertisedCaps      []string               `json:"advertised_caps,omitempty"`
}

type EphemeralRunnerJobResult added in v1.0.10

type EphemeralRunnerJobResult struct {
	RunnerID      int64    `json:"runner_id"`
	RunnerName    string   `json:"runner_name"`
	Labels        []string `json:"labels"`
	WorkflowRunID int64    `json:"workflow_run_id"`
	WorkflowJobID int64    `json:"workflow_job_id"`
	WorkerID      string   `json:"worker_id"`
	TaskID        string   `json:"task_id"`
	ArtifactRefs  []string `json:"artifact_refs"`
	CleanupStatus string   `json:"cleanup_status"`
	RedactedError string   `json:"redacted_error,omitempty"`
}

type EphemeralRunnerJobSpec added in v1.0.10

type EphemeralRunnerJobSpec struct {
	RunnerName  string   `json:"runner_name"`
	Labels      []string `json:"labels"`
	RunnerGroup string   `json:"runner_group,omitempty"`
}

func BuildEphemeralRunnerJobSpec added in v1.0.10

func BuildEphemeralRunnerJobSpec(req EphemeralRunnerJobRequest) (EphemeralRunnerJobSpec, error)

type GitEvent

type GitEvent struct {
	Provider   string          `json:"provider"`    // "github"
	EventType  string          `json:"event_type"`  // "push", "pull_request", etc.
	Repository string          `json:"repository"`  // "owner/repo"
	Branch     string          `json:"branch"`      // "main", "feature/xyz"
	Commit     string          `json:"commit"`      // SHA
	Author     string          `json:"author"`      // username
	Message    string          `json:"message"`     // commit message or PR title
	URL        string          `json:"url"`         // link to commit/PR
	RawPayload json.RawMessage `json:"raw_payload"` // original payload
	Timestamp  time.Time       `json:"timestamp"`
}

GitEvent is the normalized event schema published to the message broker.

type GitHubClient

type GitHubClient interface {
	TriggerWorkflow(ctx context.Context, owner, repo, workflow, ref string, inputs map[string]string, token string) error
	GetWorkflowRun(ctx context.Context, owner, repo string, runID int64, token string) (*WorkflowRun, error)
	CreateCheckRun(ctx context.Context, owner, repo string, req *CreateCheckRunRequest, token string) (*CheckRun, error)
}

GitHubClient is the interface for interacting with the GitHub API. It is defined as an interface so tests can inject a mock.

type GitHubRunnerClient added in v1.0.3

type GitHubRunnerClient interface {
	RegistrationToken(ctx context.Context, owner, repo, token string) (GitHubRunnerRegistrationToken, error)
	RemoveRunner(ctx context.Context, owner, repo string, runnerID int64, token string) error
	OrgRegistrationToken(ctx context.Context, organization, token string) (GitHubRunnerRegistrationToken, error)
	RemoveOrgRunner(ctx context.Context, organization string, runnerID int64, token string) error
	PreflightOrg(ctx context.Context, req GitHubRunnerProviderPreflightRequest, token string) (GitHubRunnerProviderPreflight, error)
	DispatchWorkflow(ctx context.Context, owner, repo, workflow, ref, token string) error
}

type GitHubRunnerProviderPreflight added in v1.0.10

type GitHubRunnerProviderPreflight struct {
	Organization       string   `json:"organization"`
	RunnerGroup        string   `json:"runner_group,omitempty"`
	ExistingLabels     []string `json:"existing_labels,omitempty"`
	ConflictingLabels  []string `json:"conflicting_labels,omitempty"`
	RunnerCountChecked int      `json:"runner_count_checked,omitempty"`
	ActionsEnabled     bool     `json:"actions_enabled"`
	SelfHostedAllowed  bool     `json:"self_hosted_allowed"`
}

type GitHubRunnerProviderPreflightRequest added in v1.0.10

type GitHubRunnerProviderPreflightRequest struct {
	Organization string
	RunnerGroup  string
	Labels       []string
}

type GitHubRunnerRegistrationToken added in v1.0.3

type GitHubRunnerRegistrationToken struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type SDKClient added in v1.0.2

type SDKClient struct {
	GH *github.Client
}

SDKClient wraps the go-github client with auth support.

func NewSDKClient added in v1.0.2

func NewSDKClient(token string) *SDKClient

NewSDKClient creates a client authenticated with a personal access token.

func NewSDKClientFromTransport added in v1.0.2

func NewSDKClientFromTransport(rt http.RoundTripper) *SDKClient

NewSDKClientFromTransport creates a client from an http.RoundTripper (for GitHub App auth).

type WorkflowRun

type WorkflowRun struct {
	ID         int64  `json:"id"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	HTMLURL    string `json:"html_url"`
}

WorkflowRun represents a GitHub Actions workflow run.

Jump to

Keyboard shortcuts

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