github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package github provides a client for interacting with GitHub API operations.

Index

Constants

View Source
const (
	StatusQueued     = "queued"
	StatusInProgress = "in_progress"
	StatusCompleted  = "completed"
)

RunStatus constants.

View Source
const (
	ConclusionSuccess   = "success"
	ConclusionFailure   = "failure"
	ConclusionCancelled = "cancelled" //nolint:misspell // matches GitHub Actions API's actual conclusion value
	ConclusionSkipped   = "skipped"
)

Conclusion constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the GitHub API via gh CLI.

func NewClient

func NewClient(repoFullName string) (*Client, error)

NewClient creates a new GitHub API client for the specified repository. Uses the real gh CLI executor by default.

func NewClientWithExecutor

func NewClientWithExecutor(repoFullName string, executor exec.CommandExecutor) (*Client, error)

NewClientWithExecutor creates a new GitHub API client with a custom executor. This allows injecting a mock executor for testing.

func (*Client) GetLatestRun

func (c *Client) GetLatestRun(workflowName string) (*WorkflowRun, error)

GetLatestRun fetches the most recent workflow run, optionally filtered by workflow name.

func (*Client) GetWorkflowRun

func (c *Client) GetWorkflowRun(runID int64) (*WorkflowRun, error)

GetWorkflowRun fetches a single workflow run by ID.

func (*Client) GetWorkflowRunJobs

func (c *Client) GetWorkflowRunJobs(runID int64) ([]Job, error)

GetWorkflowRunJobs fetches the jobs for a workflow run.

func (*Client) Owner

func (c *Client) Owner() string

Owner returns the repository owner.

func (*Client) Repo

func (c *Client) Repo() string

Repo returns the repository name.

type Job

type Job struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Status     string    `json:"status"`
	Conclusion string    `json:"conclusion"`
	StartedAt  time.Time `json:"started_at"`
	Steps      []Step    `json:"steps"`
}

Job represents a job within a workflow run.

type JobsResponse

type JobsResponse struct {
	TotalCount int   `json:"total_count"`
	Jobs       []Job `json:"jobs"`
}

JobsResponse represents the API response for listing jobs.

type RunsResponse

type RunsResponse struct {
	TotalCount   int           `json:"total_count"`
	WorkflowRuns []WorkflowRun `json:"workflow_runs"`
}

RunsResponse represents the API response for listing runs.

type Step

type Step struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	Number     int    `json:"number"`
}

Step represents a step within a job.

type WorkflowRun

type WorkflowRun struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Status     string    `json:"status"`
	Conclusion string    `json:"conclusion"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	HTMLURL    string    `json:"html_url"`
	HeadBranch string    `json:"head_branch"`
}

WorkflowRun represents a GitHub Actions workflow run.

func (WorkflowRun) IsActive

func (r WorkflowRun) IsActive() bool

IsActive returns true if the run is still in progress.

func (WorkflowRun) IsSuccess

func (r WorkflowRun) IsSuccess() bool

IsSuccess returns true if the run completed successfully.

Jump to

Keyboard shortcuts

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