Documentation
¶
Index ¶
- Variables
- func ArtifactDownloadURL(owner, repo string, artifactID int64) (string, error)
- func FindWorkflowArtifact(owner, repo, workflowFile, artifactName string, filter WorkflowRunFilter) (int64, error)
- func GetCommitSHA(owner, repo, ref string) (string, error)
- func GetGitHubHeaders(requestURL string) map[string]string
- func GetGitHubRelease(owner, repo, requestedVersion string) (tarballURL, downloadedRelease string, err error)
- func GetGitHubToken() (string, string)
- func GetLatestRelease(owner, repo string) (tag, htmlURL string, err error)
- func GetPullRequestHeadSHA(owner, repo string, number int) (string, error)
- func HasGitHubToken() bool
- func HasInvalidGitHubToken(response any) error
- func NightlyLinkArtifactURL(owner, repo string, artifactID int64) string
- func PullRequestArtifactURL(owner, repo string, number int, artifactName string) (string, error)
- type Client
- type ListOptions
- type Repository
- type SearchOptions
- type WorkflowRunFilter
Constants ¶
This section is empty.
Variables ¶
var ErrNoSuccessfulRun = errors.New("no successful run found")
ErrNoSuccessfulRun is returned by FindWorkflowArtifact when no successful run matches the filter.
Functions ¶
func ArtifactDownloadURL ¶ added in v1.25.5
ArtifactDownloadURL returns the short-lived (~1 minute) presigned URL for an artifact's .zip. GitHub requires a token for this even on public repositories, so unlike the lookups it never retries anonymously.
func FindWorkflowArtifact ¶ added in v1.25.5
func FindWorkflowArtifact(owner, repo, workflowFile, artifactName string, filter WorkflowRunFilter) (int64, error)
FindWorkflowArtifact finds the newest successful run of workflowFile matching filter and returns the ID of its artifact named artifactName. Listing runs and artifacts works anonymously for public repositories, subject to GitHub's unauthenticated rate limit.
func GetCommitSHA ¶ added in v1.25.5
GetCommitSHA returns the full SHA that ref, such as an abbreviated SHA, points to.
func GetGitHubHeaders ¶ added in v1.24.8
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. With an empty requestedVersion it returns the release GitHub marks as latest, or the newest non-draft release when every release is a prerelease.
func GetGitHubToken ¶ added in v1.24.8
GetGitHubToken returns the GitHub token from the environment and the name of the variable it was found in.
func GetLatestRelease ¶ added in v1.25.5
GetLatestRelease returns the tag name and HTML page URL 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
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
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
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
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).
Types ¶
type Client ¶ added in v1.24.8
func GetGitHubClient ¶ added in v1.24.8
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
WorkflowRunFilter selects a GitHub Actions workflow run by branch and/or head SHA.