github

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitHubHeaders added in v1.24.8

func GetGitHubHeaders(requestURL string) map[string]string

GetGitHubHeaders returns headers to be used in GitHub REST API requests if the URL is for GitHub. See https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api

func GetGitHubRelease added in v1.24.8

func GetGitHubRelease(owner, repo, requestedVersion string) (tarballURL, downloadedRelease string, err error)

GetGitHubRelease gets the tarball URL and version for a GitHub repository release

func GetGitHubToken added in v1.24.8

func GetGitHubToken() (string, string)

GetGitHubToken returns the GitHub token from the environment and the name of the variable it was found in.

func GetLatestReleaseTag added in v1.25.4

func GetLatestReleaseTag(owner, repo string) (string, error)

GetLatestReleaseTag returns the tag name of the latest release for owner/repo. It uses GitHub's "latest release" endpoint, which excludes drafts and prereleases.

func GetPullRequestHeadSHA added in v1.25.4

func GetPullRequestHeadSHA(owner, repo string, number int) (string, error)

GetPullRequestHeadSHA returns the head commit SHA of a pull request.

func HasGitHubToken added in v1.24.9

func HasGitHubToken() bool

HasGitHubToken returns true if a GitHub token is set in the environment.

func HasInvalidGitHubToken added in v1.24.9

func HasInvalidGitHubToken(response any) error

HasInvalidGitHubToken checks if the response indicates an invalid GitHub token. This is possible if we get 401 or 404 response.

func NightlyLinkArtifactURL added in v1.25.4

func NightlyLinkArtifactURL(owner, repo string, artifactID int64) string

NightlyLinkArtifactURL returns the nightly.link URL for a specific artifact ID. nightly.link is a third-party service that serves GitHub Actions artifacts for public repositories without requiring authentication.

func PullRequestArtifactURL added in v1.25.4

func PullRequestArtifactURL(owner, repo string, number int, artifactName string) (string, error)

PullRequestArtifactURL returns a nightly.link download URL for artifactName by reading the pull request's HTML page and extracting the link posted there by the pr-artifacts-comment workflow. It uses no GitHub API token or API-rate budget, so it is a useful fallback when the API is rate-limited, but it works only for public repositories and only once that bot comment exists (that is, after the PR's build has finished).

func ResolveWorkflowArtifactURL added in v1.25.4

func ResolveWorkflowArtifactURL(owner, repo, workflowFile, artifactName string, filter WorkflowRunFilter) (string, error)

ResolveWorkflowArtifactURL finds the newest successful run of workflowFile matching filter and returns a URL from which the artifact named artifactName can be downloaded as a .zip.

Listing runs and artifacts works anonymously for public repositories (subject to GitHub's unauthenticated rate limit). The artifact zip itself cannot be downloaded anonymously from the GitHub API, so when a token is available this returns the authenticated Actions download URL; otherwise it returns a nightly.link URL (a third-party redirector that works only for public repos).

Types

type Client added in v1.24.8

type Client = github.Client

func GetGitHubClient added in v1.24.8

func GetGitHubClient(withAuth bool) (context.Context, *Client, error)

GetGitHubClient returns a context and a singleton GitHub client, initializing it once. With withAuth, it returns the token-authenticated client; otherwise the no-auth client. The returned error is non-nil if the requested client failed to initialize.

type ListOptions added in v1.24.8

type ListOptions = github.ListOptions

type Repository added in v1.24.8

type Repository = github.Repository

type SearchOptions added in v1.24.8

type SearchOptions = github.SearchOptions

type WorkflowRunFilter added in v1.25.4

type WorkflowRunFilter struct {
	Branch  string
	HeadSHA string
	Event   string
}

WorkflowRunFilter selects a GitHub Actions workflow run by branch and/or head SHA.

Jump to

Keyboard shortcuts

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