Documentation
¶
Index ¶
- func GetGitHubHeaders(requestURL string) map[string]string
- func GetGitHubRelease(owner, repo, requestedVersion string) (tarballURL, downloadedRelease string, err error)
- func GetGitHubToken() (string, string)
- func GetLatestReleaseTag(owner, repo string) (string, 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)
- func ResolveWorkflowArtifactURL(owner, repo, workflowFile, artifactName string, filter WorkflowRunFilter) (string, error)
- type Client
- type ListOptions
- type Repository
- type SearchOptions
- type WorkflowRunFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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 GetLatestReleaseTag ¶ added in v1.25.4
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
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).
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
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.