github

package
v3.126.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAsset added in v3.84.0

func DownloadAsset(ctx context.Context, token string, a ReleaseAsset, destDir string) (string, error)

DownloadAsset writes an asset into destDir and returns its path.

Types

type Artifact

type Artifact struct {
	ID                 int64     `json:"id"`
	NodeID             string    `json:"node_id"`
	Name               string    `json:"name"`
	SizeInBytes        int64     `json:"size_in_bytes"`
	URL                string    `json:"url"`
	ArchiveDownloadURL string    `json:"archive_download_url"`
	Expired            bool      `json:"expired"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	ExpiresAt          time.Time `json:"expires_at"`
}

Artifact represents a GitHub Actions artifact

type ArtifactCollector

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

ArtifactCollector handles collection of GitHub Actions artifacts

func NewArtifactCollector

func NewArtifactCollector(token, apiURL, repository, runID string) *ArtifactCollector

NewArtifactCollector creates a new artifact collector

func (*ArtifactCollector) DownloadArtifact

func (c *ArtifactCollector) DownloadArtifact(ctx context.Context, artifact Artifact) (string, error)

DownloadArtifact downloads an artifact and extracts it to a temporary directory

func (*ArtifactCollector) GetRepository added in v3.73.0

func (c *ArtifactCollector) GetRepository(ctx context.Context) (*Repository, error)

GetRepository fetches the repository's metadata.

func (*ArtifactCollector) GetWorkflowRun added in v3.73.0

func (c *ArtifactCollector) GetWorkflowRun(ctx context.Context) (*WorkflowRun, error)

GetWorkflowRun fetches this run's metadata.

func (*ArtifactCollector) ListArtifacts

func (c *ArtifactCollector) ListArtifacts(ctx context.Context) ([]Artifact, error)

ListArtifacts lists all artifacts for the current workflow run

func (*ArtifactCollector) ListPullsForCommit added in v3.73.0

func (c *ArtifactCollector) ListPullsForCommit(ctx context.Context, sha string) ([]PullRequestRef, error)

ListPullsForCommit finds the pull requests a commit belongs to. Used on a push to a branch that has an open PR, where the event payload carries no PR number.

type ArtifactMetadata

type ArtifactMetadata struct {
	Repository      string            `json:"repository"`
	RepositoryOwner string            `json:"repository_owner"`
	RunID           string            `json:"run_id"`
	RunNumber       string            `json:"run_number"`
	WorkflowName    string            `json:"workflow_name"`
	JobName         string            `json:"job"`
	SHA             string            `json:"sha"`
	RefName         string            `json:"ref_name"`
	RefType         string            `json:"ref_type"`
	EventName       string            `json:"event_name"`
	Actor           string            `json:"actor"`
	ServerURL       string            `json:"server_url"`
	APIURL          string            `json:"api_url"`
	Artifacts       []string          `json:"artifacts"`
	ExtraEnvVars    map[string]string `json:"extra_env_vars,omitempty"`
}

ArtifactMetadata contains metadata about the workflow and artifacts

func CollectMetadata

func CollectMetadata(artifactNames []string) *ArtifactMetadata

CollectMetadata collects metadata from GitHub Actions environment

type ArtifactsResponse

type ArtifactsResponse struct {
	TotalCount int        `json:"total_count"`
	Artifacts  []Artifact `json:"artifacts"`
}

ArtifactsResponse represents the GitHub API response for artifacts

type PullRequestRef added in v3.73.0

type PullRequestRef struct {
	Number int    `json:"number"`
	State  string `json:"state"`
	Base   struct {
		Ref string `json:"ref"`
	} `json:"base"`
	Head struct {
		Ref string `json:"ref"`
	} `json:"head"`
}

PullRequestRef is one PR a commit belongs to.

type Release added in v3.84.0

type Release struct {
	TagName string         `json:"tag_name"`
	Assets  []ReleaseAsset `json:"assets"`
}

func FetchReleaseByTag added in v3.84.0

func FetchReleaseByTag(ctx context.Context, token, apiURL, repository, tag string) (*Release, error)

FetchReleaseByTag reads one release by its tag.

apiURL is a parameter rather than a constant because GitHub Enterprise serves a different host, and guessing github.com there would read the wrong instance.

func (*Release) AssetMatching added in v3.84.0

func (r *Release) AssetMatching(substr string) *ReleaseAsset

AssetMatching finds the first asset whose name contains substr, ignoring case.

Substring rather than exact match because projects spell the same file checksums.txt, SHA256SUMS and tool_checksums.txt, and requiring each repository to declare which would be a per-repository input for a question the release itself already answers.

type ReleaseAsset added in v3.84.0

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

type Repository added in v3.73.0

type Repository struct {
	ID            int64  `json:"id"`
	FullName      string `json:"full_name"`
	Private       bool   `json:"private"`
	Visibility    string `json:"visibility"`
	DefaultBranch string `json:"default_branch"`
	Owner         *User  `json:"owner"`
	License       *struct {
		SpdxID string `json:"spdx_id"`
	} `json:"license"`
}

Repository is the subset of GET /repos/{repo} worth keeping.

type User added in v3.73.0

type User struct {
	Login string `json:"login"`
	Type  string `json:"type"`
}

User is a GitHub account reference.

type WorkflowRun added in v3.73.0

type WorkflowRun struct {
	ID              int64  `json:"id"`
	Name            string `json:"name"`
	RunNumber       int    `json:"run_number"`
	RunAttempt      int    `json:"run_attempt"`
	Event           string `json:"event"`
	Status          string `json:"status"`
	Conclusion      string `json:"conclusion"`
	HeadBranch      string `json:"head_branch"`
	HeadSHA         string `json:"head_sha"`
	HTMLURL         string `json:"html_url"`
	Path            string `json:"path"`
	Actor           *User  `json:"actor"`
	TriggeringActor *User  `json:"triggering_actor"`
	PullRequests    []struct {
		Number int `json:"number"`
	} `json:"pull_requests"`
}

WorkflowRun is the subset of GET /repos/{repo}/actions/runs/{id} worth keeping.

Jump to

Keyboard shortcuts

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