github

package
v1.32.0-163.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIRPS = 10
)

Variables

This section is empty.

Functions

func CommitURL

func CommitURL(repo, sha string) string

CommitURL constructs a GitHub commit URL.

func DownloadArtifact

func DownloadArtifact(ctx context.Context, repo string, artifactID int64, outputDir string) (string, error)

DownloadArtifact downloads a single GitHub Actions artifact zip file.

func JobURL

func JobURL(repo, runID, jobID string) string

JobURL constructs a GitHub Actions job URL.

func RunDownload

func RunDownload(ctx context.Context, runID string, opts RunDownloadOptions) error

RunDownload executes `gh run download`.

func RunURL

func RunURL(repo, runID string) string

RunURL constructs a GitHub Actions workflow run URL.

func SetAPIRPS

func SetAPIRPS(rps int) error

SetAPIRPS sets the request rate limit for GitHub API requests.

Types

type Artifact

type Artifact struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	Expired   bool      `json:"expired"`
}

Artifact represents a downloadable GitHub Actions artifact.

func ListRunArtifacts

func ListRunArtifacts(ctx context.Context, repo string, githubActionsRunID int64) ([]Artifact, error)

ListRunArtifacts retrieves artifacts for a GitHub Actions workflow run.

type Commit

type Commit struct {
	SHA    string        `json:"sha"`
	Commit CommitDetails `json:"commit"`
	Files  []CommitFile  `json:"files"`
}

Commit holds changed-file info fetched from the GitHub API.

func GetCommit

func GetCommit(ctx context.Context, repo, sha string) (Commit, error)

GetCommit fetches commit metadata from the GitHub API. Uses: GET /repos/{owner}/{repo}/commits/{sha}

func (Commit) Filenames

func (c Commit) Filenames() []string

Filenames returns the names of the files changed by the commit.

func (Commit) Title

func (c Commit) Title() string

Title returns the first line of the commit message.

type CommitAuthor

type CommitAuthor struct {
	Name string    `json:"name"`
	Date time.Time `json:"date"`
}

CommitAuthor holds the commit author nested in the GitHub API response.

type CommitDetails

type CommitDetails struct {
	Message string       `json:"message"`
	Author  CommitAuthor `json:"author"`
}

CommitDetails holds the commit metadata nested in the GitHub API response.

type CommitFile

type CommitFile struct {
	Filename string `json:"filename"`
}

CommitFile holds a changed file in the GitHub API response.

type Conclusion

type Conclusion string

Conclusion represents the conclusion status of a workflow run or job.

const (
	ConclusionSuccess Conclusion = "success"
	ConclusionFailure Conclusion = "failure"
)

type Job

type Job struct {
	Name        string     `json:"name"`
	Conclusion  Conclusion `json:"conclusion"`
	Status      string     `json:"status"`
	StartedAt   string     `json:"startedAt"`
	CompletedAt string     `json:"completedAt"`
	URL         string     `json:"url"`
}

Job represents a single job in a GitHub Actions workflow run returned by the gh CLI.

type RateLimitError

type RateLimitError struct {
	Status         string
	RetryAfter     time.Duration
	RetryAttempted bool
	Err            error
}

RateLimitError indicates GitHub continued rate limiting after the requested retry.

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

func (*RateLimitError) Unwrap

func (e *RateLimitError) Unwrap() error

type Run

type Run struct {
	DatabaseID         int64         `json:"databaseId"`
	Number             int           `json:"number"`
	Name               string        `json:"name"`
	WorkflowName       string        `json:"workflowName"`
	WorkflowDatabaseID int64         `json:"workflowDatabaseId"`
	Status             string        `json:"status"`
	Conclusion         Conclusion    `json:"conclusion"`
	HeadBranch         string        `json:"headBranch"`
	HeadSHA            string        `json:"headSha"`
	URL                string        `json:"url"`
	DisplayTitle       string        `json:"displayTitle"`
	Event              string        `json:"event"`
	CreatedAt          time.Time     `json:"createdAt"`
	StartedAt          time.Time     `json:"startedAt"`
	UpdatedAt          time.Time     `json:"updatedAt"`
	Duration           time.Duration `json:"-"`
	Jobs               []Job         `json:"jobs"`
}

Run represents a GitHub Actions workflow run returned by the gh CLI.

func ListRuns

func ListRuns(ctx context.Context, opts RunListOptions) ([]Run, error)

ListRuns retrieves workflow runs through the gh CLI.

func ViewRun

func ViewRun(ctx context.Context, runID string) (Run, error)

ViewRun retrieves workflow run details through the gh CLI.

func (Run) ShortSHA

func (r Run) ShortSHA() string

ShortSHA returns the first seven characters of the run's commit SHA.

type RunDownloadOptions

type RunDownloadOptions struct {
	Repo    string
	Pattern string
	Dir     string
}

RunDownloadOptions configures `gh run download`.

type RunListOptions

type RunListOptions struct {
	Repo       string
	WorkflowID int64
	Branch     string
	Workflow   string
	Event      string
	Status     string
	Created    string
	Limit      int
	All        bool
}

RunListOptions configures workflow-run listing.

Jump to

Keyboard shortcuts

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