{"modulePath":"github.com/cloudposse/atmos","version":"v1.235.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Variables\n\n```go\nvar (\n\t// ErrPRNotFound indicates the PR does not exist.\n\tErrPRNotFound = errors.New(\"pull request not found\")\n\n\t// ErrNoWorkflowRunFound indicates no workflow run was found for the PR.\n\tErrNoWorkflowRunFound = errors.New(\"no workflow run found\")\n\n\t// ErrNoArtifactFound indicates the requested artifact was not found.\n\tErrNoArtifactFound = errors.New(\"artifact not found\")\n\n\t// ErrNoArtifactForPlatform indicates no artifact exists for the current platform.\n\tErrNoArtifactForPlatform = errors.New(\"no artifact available for current platform\")\n\n\t// ErrRefNotFound indicates the git ref (branch or tag) does not exist.\n\tErrRefNotFound = errors.New(\"git ref not found\")\n)\n```\nArtifact-related errors.\n\n```go\nvar (\n\t// ErrInvalidGitHubURL indicates the GitHub URL format is invalid.\n\tErrInvalidGitHubURL = errors.New(\"invalid GitHub URL\")\n\n\t// ErrUnsupportedGitHubHost indicates the GitHub host is not supported.\n\tErrUnsupportedGitHubHost = errors.New(\"unsupported GitHub host\")\n\n\t// ErrNoVersionsFound indicates no versions were found for a repository.\n\tErrNoVersionsFound = errors.New(\"no versions found\")\n)\n```\nError definitions for the github package.\n\n```go\nvar ErrGitHubTokenRequired = errors.New(\"GitHub token required\")\n```\nErrGitHubTokenRequired indicates that a GitHub token is required but not found.\n\n```go\nvar ErrPathNotFound = errors.New(\"path not found\")\n```\nErrPathNotFound indicates the requested directory does not exist at the requested ref.\n\n```go\nvar ErrTreeListingIncomplete = errors.New(\"repository directory listing may be incomplete\")\n```\nErrTreeListingIncomplete means the contents API limit prevents proving a path is absent.\n\n```go\nvar RateLimitWaiter = waitForRateLimitImpl\n```\nRateLimitWaiter is the function used to wait for rate limits. Tests can override this to skip the actual wait.\n\n## Functions\n\n```go\nfunc ConvertToRawURL(githubURL string) (string, error)\n```\nConvertToRawURL converts a GitHub repository URL to its raw content URL. Supports various GitHub URL formats and converts them to raw content URLs: on github.com that is raw.githubusercontent.com; on a GitHub Enterprise Server host configured via RepoEndpoints (GITHUB\\_SERVER\\_URL/GITHUB\\_API\\_URL), raw content is served from the same host under /raw/ instead.\n\nExamples (github.com):\n\n  - [https://github.com/owner/repo/blob/main/path/file.yaml](https://github.com/owner/repo/blob/main/path/file.yaml) → [https://raw.githubusercontent.com/owner/repo/main/path/file.yaml](https://raw.githubusercontent.com/owner/repo/main/path/file.yaml)\n  - [https://github.com/owner/repo/tree/v1.0.0/path](https://github.com/owner/repo/tree/v1.0.0/path) → [https://raw.githubusercontent.com/owner/repo/v1.0.0/path](https://raw.githubusercontent.com/owner/repo/v1.0.0/path)\n  - github://owner/repo/path/file.yaml@branch → [https://raw.githubusercontent.com/owner/repo/branch/path/file.yaml](https://raw.githubusercontent.com/owner/repo/branch/path/file.yaml)\n  - github://owner/repo@v1.0.0 → [https://raw.githubusercontent.com/owner/repo/v1.0.0](https://raw.githubusercontent.com/owner/repo/v1.0.0)\n\n```go\nfunc GetArtifactDownloadURL(ctx context.Context, owner, repo string, artifactID int64) (string, error)\n```\nGetArtifactDownloadURL returns the download URL for a specific artifact. Downloads from public repositories work without authentication (subject to rate limits); private repositories require a token.\n\n```go\nfunc GetGitHubToken() string\n```\nGetGitHubToken retrieves a GitHub token using multiple fallback strategies. The token is required for operations that need authentication (e.g., downloading PR artifacts).\n\nDetection order:\n\n 1. \\--github-token CLI flag (via viper, for toolchain commands)\n 2. ATMOS\\_GITHUB\\_TOKEN environment variable\n 3. GITHUB\\_TOKEN environment variable\n 4. \\`gh auth token\\` command output (if GitHub CLI is installed)\n\nReturns the token if found, or an empty string if no token is available. Use GetGitHubTokenOrError if you need to require authentication.\n\n```go\nfunc GetGitHubTokenContext(ctx context.Context) string\n```\nGetGitHubTokenContext resolves an optional token while honoring caller cancellation.\n\n```go\nfunc GetGitHubTokenFromCLI() string\n```\nGetGitHubTokenFromCLI attempts to get a token from the GitHub CLI. Returns empty string if the CLI is not installed, not authenticated, or disabled.\n\nThe CLI binary is configurable via the ATMOS\\_GITHUB\\_CLI environment variable (defaults to \"gh\"). Setting it to an empty value disables the fallback, and setting it to a nonexistent binary forces the unauthenticated/anonymous path (useful for exercising public access).\n\nExported so other packages needing GitHub CLI token resolution (e.g. the git-clone token injection in pkg/downloader) can call the same fallback without duplicating it.\n\n```go\nfunc GetGitHubTokenFromCLIContext(parent context.Context) string\n```\nGetGitHubTokenFromCLIContext bounds the CLI lookup by both caller cancellation and the existing five-second CLI timeout. Cancellation leaves the token empty.\n\n```go\nfunc GetGitHubTokenOrError() (string, error)\n```\nGetGitHubTokenOrError retrieves a GitHub token or returns an error if none is found. Use this when authentication is required (e.g., downloading PR artifacts).\n\n```go\nfunc GetLatestRelease(owner string, repo string) (string, error)\n```\nGetLatestRelease returns the latest release tag for a GitHub repository.\n\n```go\nfunc GetLatestReleaseInfo(owner, repo string) (*github.RepositoryRelease, error)\n```\nGetLatestReleaseInfo fetches the latest stable release from GitHub.\n\n```go\nfunc GetPRHeadSHA(ctx context.Context, owner, repo string, prNumber int, token string) (string, error)\n```\nGetPRHeadSHA retrieves the current head commit SHA for a pull request. This is used for cache validation to check if the PR has new commits. The token parameter is used for API authentication if available; empty string for unauthenticated access.\n\n```go\nfunc GetRefSHA(ctx context.Context, owner, repo, ref string) (string, error)\n```\nGetRefSHA resolves a git ref (branch or tag name) to its full commit SHA. It accepts bare names (\"main\", \"v1.2.3\") as well as qualified refs (\"heads/main\", \"tags/v1.2.3\") for disambiguation. The returned SHA is the full 40-character commit SHA, which is what the artifact lookup requires. Works without authentication for public repositories (subject to rate limits).\n\n```go\nfunc GetReleaseByTag(owner, repo, tag string) (*github.RepositoryRelease, error)\n```\nGetReleaseByTag fetches a specific GitHub release by tag name.\n\n```go\nfunc GetReleaseVersions(owner, repo string, limit int) ([]string, error)\n```\nGetReleaseVersions fetches release versions as strings (tag names without 'v' prefix). Returns only non-prerelease versions, for toolchain version management: it is scoped to ToolchainEndpoints, not RepoEndpoints, since toolchain-managed tool releases live on public github.com by default even for GHES users.\n\n```go\nfunc GetReleases(opts ReleasesOptions) ([]*github.RepositoryRelease, error)\n```\nGetReleases fetches GitHub releases with pagination, prerelease filtering, and date filtering, scoped to RepoEndpoints (the user's own repositories).\n\n```go\nfunc IsApprovedGitHubDownloadHost(host string) bool\n```\nIsApprovedGitHubDownloadHost reports whether host (case-insensitive, with port and trailing dot normalized) is a server, API, or upload host that RepoEndpoints() or ToolchainEndpoints() resolves to. Used to validate a GitHub-issued download or redirect URL (e.g. a PR-artifact archive download, which redirects to a pre-signed, unauthenticated blob URL) before deciding whether it is safe to attach a bearer token to a request against it.\n\n```go\nfunc IsArchived(ctx context.Context, owner, repo string) (bool, error)\n```\nIsArchived reports whether a GitHub repository is archived. Archived-ness is repository metadata only exposed by the GitHub REST API (the \\`Archived\\` field on \\*github.Repository\\`), not by the git wire protocol used for tag listing, so this is a separate API call/round-trip from ListTags. Authentication and rate-limit handling follow the shared client behavior (see newGitHubClient/handleGitHubAPIError).\n\n```go\nfunc IsNoArtifactError(err error) bool\n```\nIsNoArtifactError checks if the error is a \"no artifact\" error.\n\n```go\nfunc IsNoWorkflowError(err error) bool\n```\nIsNoWorkflowError checks if the error is a \"no workflow run\" error.\n\n```go\nfunc IsNotFoundError(err error) bool\n```\nIsNotFoundError checks if the error is a \"not found\" type error.\n\n```go\nfunc IsPlatformError(err error) bool\n```\nIsPlatformError checks if the error is a platform-related error.\n\n```go\nfunc IsPublicGitHubHost(host string) bool\n```\nIsPublicGitHubHost reports whether host (case-insensitive, with port and trailing dot normalized) is public github.com, independent of whatever RepoEndpoints resolves to. Callers that must still recognize an explicit public github.com URL even when GITHUB\\_SERVER\\_URL points at a GitHub Enterprise Server host (e.g. converting a public github.com blob URL to raw content for an !include, regardless of the caller's own GHES configuration) should check this in addition to RepoEndpoints().IsHost.\n\n```go\nfunc ListTags(ctx context.Context, owner, repo string) ([]*github.RepositoryTag, error)\n```\nListTags returns all tags for a repository, newest first as reported by the GitHub API, including each tag's commit SHA. Pagination is handled internally; authentication and rate-limit handling follow the shared client behavior.\n\n```go\nfunc NewScopedTokenHTTPClient(token string, allowed Endpoints, timeout time.Duration) *http.Client\n```\nNewScopedTokenHTTPClient returns an \\*http.Client, honoring timeout, that attaches \"Authorization: Bearer \\\u003ctoken\u003e\" to a request only when -- re-evaluated on every hop of an automatic redirect, not decided once up front -- the request's own URL is https and its host matches allowed's server, API, or upload host. Token is passed through TokenForEndpoints first, so an empty result (allowed's own API host is not https) means no request ever carries a token, matching newGitHubClientForEndpoints' existing behavior for that case.\n\nCentralizes the fix for a class of bug where a token is decided once from an initial URL/host, then a redirect (cross-host, or the same host downgraded from https to http) sends it somewhere it was never scoped to: pkg/ci/artifact/github/store.go, pkg/ci/cache/github, and pkg/github's own GitHub API client all build their \\*http.Client this way.\n\n```go\nfunc ParseOwnerRepo(gitURI string) (owner, repo string, ok bool)\n```\nParseOwnerRepo extracts the owner and repository name from a Git URI, as produced by version.ExtractGitURI (e.g. \"[https://github.com/owner/repo.git](https://github.com/owner/repo.git)\"). It returns ok=false for any URI that isn't a github.com repository (GitLab, Bitbucket, self-hosted Git servers, etc.), so callers can skip GitHub-only capabilities (like archived-repo detection) for those sources without treating it as an error.\n\n```go\nfunc ResolveEndpointURL(envVar, fallback string) string\n```\nResolveEndpointURL reads envVar and returns its value trimmed of a trailing slash, or fallback when the variable is unset or its value fails to parse as an absolute HTTP(S) URL, or when it carries a query string, fragment, or userinfo component. A base URL is only ever used as a prefix that owner/repo/ref/path segments are appended to (see e.g. RawURL, ReleaseAssetURL, ArchiveURL): a RawQuery would silently vanish once those segments are appended after it (net/url's String() places the query after the whole path), a Fragment would do the same, and a User component would leak credentials into every URL built from it and complicate host comparisons that assume a bare authority. Invalid values are never fatal: they are logged at debug level and the caller falls back to the default endpoint, matching today's behavior for anyone not opting into GHES. Exported because it is shared by the toolchain registries (e.g. the aqua package's RegistryBaseURL) in addition to RepoEndpoints and ToolchainEndpoints above.\n\nhttp:// is accepted here on purpose: the acceptance and unit test suites point these endpoints at local httptest/httpmock servers over plain HTTP, and resolution must keep working for them. Accepting http here is not itself a credential leak -- the leak would be attaching a token to a request built against a non-https endpoint, which is prevented centrally by TokenForEndpoints (and newGitHubClientForEndpoints, which calls it), not by rejecting http endpoints here.\n\n```go\nfunc SetCommanderForTesting(c execpkg.CommandExecutor) (restore func())\n```\nSetCommanderForTesting overrides the package-level GitHub CLI command executor, for tests in other packages that exercise GetGitHubTokenFromCLI indirectly (e.g. pkg/downloader's git-clone token injection). Returns a restore func the caller must invoke (typically via t.Cleanup) to put the original commander back.\n\n```go\nfunc ShouldWaitForRateLimit(ctx context.Context, minRemaining int) bool\n```\nShouldWaitForRateLimit checks if rate limit is low enough to warrant waiting. This is a non-blocking check that just returns the decision.\n\n```go\nfunc ShouldWaitForRateLimitWithService(ctx context.Context, service RateLimitService, minRemaining int) bool\n```\nShouldWaitForRateLimitWithService checks if rate limit is low using a custom service. This is primarily used for testing with mock services.\n\n```go\nfunc SupportedPRPlatforms() []string\n```\nSupportedPRPlatforms returns a list of platforms supported by PR artifact downloads.\n\n```go\nfunc TokenForEndpoints(endpoints Endpoints, token string) string\n```\nTokenForEndpoints returns token unchanged when endpoints.AllowsToken() (its API host is https), or \"\" otherwise, logging at debug level so a non-https endpoint that withholds a configured token is diagnosable rather than silently degrading to anonymous access. This centralizes the \"never send a token over http\" rule for every caller that builds an authenticated GitHub request or client from RepoEndpoints()/ToolchainEndpoints().\n\n```go\nfunc TreeSHA(ctx context.Context, owner, repo, ref, dirPath string) (string, error)\n```\nTreeSHA returns the Git tree SHA of the directory at dirPath in owner/repo at ref. Two directories with the same tree SHA have byte-identical contents, so comparing them proves a directory moved between repositories without changing. The path must name a directory below the repository root.\n\nThe SHA is read from the parent directory listing, which carries the object SHA of every entry, so each lookup costs one request. A limit-sized listing that omits the directory returns ErrTreeListingIncomplete rather than claiming absence. A missing ref wraps ErrRefNotFound and a missing directory wraps ErrPathNotFound; any other failure is returned as the shared client reports it (rate limiting and rejected credentials included).\n\nThe repositories compared are public, so when GITHUB\\_SERVER\\_URL points at a GitHub Enterprise Server the lookup still targets public github.com, without sending the server-scoped token.\n\n```go\nfunc WaitForRateLimit(ctx context.Context, minRemaining int) error\n```\nWaitForRateLimit checks GitHub rate limits and waits if necessary. If remaining requests are below minRemaining, it waits until the rate limit resets. Uses a spinner UI in TTY mode, otherwise simple output. Returns nil on success or context cancellation error. Does not return error on rate limit check failures (to avoid blocking operations).\n\n## Types\n\n```go\ntype ActionsService interface {\n\tListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *github.ListWorkflowRunsOptions) (*github.WorkflowRuns, *github.Response, error)\n\tListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *github.ListOptions) (*github.ArtifactList, *github.Response, error)\n\tGetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*github.Artifact, *github.Response, error)\n}\n```\nActionsService defines the interface for GitHub Actions operations. This allows for mocking in tests.\n\n```go\ntype ArtifactFetcher struct {\n\t// contains filtered or unexported fields\n}\n```\nArtifactFetcher wraps the artifact fetching logic with injectable services. Use NewArtifactFetcher to create an instance with custom services for testing.\n\n```go\nfunc NewArtifactFetcher(prs PullRequestService, actions ActionsService) *ArtifactFetcher\n```\nNewArtifactFetcher creates an ArtifactFetcher with custom services. This is primarily used for testing with mock services.\n\n```go\nfunc NewToolchainArtifactFetcher(ctx context.Context) *ArtifactFetcher\n```\nNewToolchainArtifactFetcher returns an ArtifactFetcher backed by a GitHub client scoped to ToolchainEndpoints rather than RepoEndpoints. Use this (instead of the free GetPRArtifactInfo/ GetPRHeadSHA/GetSHAArtifactInfo/GetRefSHA functions) when fetching build artifacts of a toolchain-managed repository -- e.g. atmos's own PR/SHA/ref build artifacts for self-install -- which live on public github.com by default even for GHES users.\n\n```go\nfunc (f *ArtifactFetcher) GetArtifactDownloadURL(ctx context.Context, owner, repo string, artifactID int64) (string, error)\n```\nGetArtifactDownloadURL returns the download URL using custom services.\n\n```go\nfunc (f *ArtifactFetcher) GetPRArtifactInfo(ctx context.Context, owner, repo string, prNumber int) (*PRArtifactInfo, error)\n```\nGetPRArtifactInfo retrieves build artifact info for a PR using custom services.\n\n```go\nfunc (f *ArtifactFetcher) GetPRHeadSHA(ctx context.Context, owner, repo string, prNumber int) (string, error)\n```\nGetPRHeadSHA retrieves the head SHA for a PR using custom services.\n\n```go\nfunc (f *ArtifactFetcher) GetRefSHA(ctx context.Context, owner, repo, ref string) (string, error)\n```\nGetRefSHA resolves a git ref to its full commit SHA using custom services.\n\n```go\nfunc (f *ArtifactFetcher) GetSHAArtifactInfo(ctx context.Context, owner, repo, sha string) (*SHAArtifactInfo, error)\n```\nGetSHAArtifactInfo retrieves build artifact info for a SHA using custom services.\n\n```go\ntype Endpoints struct {\n\t// ServerURL is the web/clone host, e.g. \"https://github.com\" or \"https://ghes.example.com\".\n\tServerURL string\n\t// APIURL is the REST API base, e.g. \"https://api.github.com\" or \"https://ghes.example.com/api/v3\".\n\tAPIURL string\n\t// UploadURL is the API host used for release asset uploads, e.g. \"https://uploads.github.com\"\n\t// on github.com, or \"\u003cServerURL\u003e/api/uploads\" on GHES.\n\tUploadURL string\n\t// Host is the normalized host of ServerURL (lowercased, no trailing dot, no default port).\n\t// It may still carry a non-default port (e.g. \"ghes.example.com:8443\") -- normalizeHost\n\t// only strips the default 80/443 ports, so a GHES host (or test mock) reachable only on a\n\t// non-default port keeps that port here and can still match its own URLs via IsHost.\n\tHost string\n}\n```\nEndpoints describes where a set of GitHub (or GitHub Enterprise Server) resources live: the web UI/clone host, the REST API host, and the derived upload host. Two independent concerns resolve to their own Endpoints value:\n\n  - RepoEndpoints reads GITHUB\\_SERVER\\_URL / GITHUB\\_API\\_URL — where the \\*user's\\* repositories live (CI provider, imports/vendoring, releases/tags/artifacts API, token host allowlist).\n  - ToolchainEndpoints reads ATMOS\\_TOOLCHAIN\\_GITHUB\\_URL / ATMOS\\_TOOLCHAIN\\_GITHUB\\_API\\_URL — where toolchain release assets live. This is deliberately separate: toolchain assets (and the aqua-registry mirror, resolved independently by the aqua package) live on public github.com even for GHES users, so the toolchain must not follow the repo vars (doing so would break \\`atmos toolchain install\\` on every GHES runner).\n\nBoth env vars, on both constructors, default to public GitHub.com so behavior is byte-identical to today when unset.\n\n```go\nfunc RepoEndpoints() Endpoints\n```\nRepoEndpoints resolves the endpoints for the user's own repositories from the standard GITHUB\\_SERVER\\_URL / GITHUB\\_API\\_URL environment variables (the same variables GitHub Actions exports on both github.com and GitHub Enterprise Server runners). Consumed by the CI provider, imports/vendoring raw fetches, the pkg/github API client, the token host allowlist, and token-injection host recognition.\n\n```go\nfunc ToolchainEndpoints() Endpoints\n```\nToolchainEndpoints resolves the endpoints for toolchain release assets and archives from ATMOS\\_TOOLCHAIN\\_GITHUB\\_URL / ATMOS\\_TOOLCHAIN\\_GITHUB\\_API\\_URL. These are separate from RepoEndpoints because aqua-registry tools are hosted on public github.com even when the user's own repositories live on a GitHub Enterprise Server. Useful for corporate release proxies/mirrors that front public GitHub releases.\n\n```go\nfunc (e Endpoints) AllowsToken() bool\n```\nAllowsToken reports whether it is safe to attach a bearer/OAuth token to a request against this Endpoints value's API host: only when APIURL resolves to an https URL. Sending a token over plain HTTP would put it on the wire in cleartext. ResolveEndpointURL intentionally accepts http:// (the acceptance/unit test suites point endpoints at local httptest/httpmock servers over plain HTTP), so those endpoints must still resolve -- they simply must never be paired with a token.\n\n```go\nfunc (e Endpoints) ArchiveURL(owner, repo, tag string) string\n```\nArchiveURL builds the URL for downloading a tag's source archive (\\`/\\\u003cowner\u003e/\\\u003crepo\u003e/archive/refs/tags/\\\u003ctag\u003e.tar.gz\\`), identical on github.com and GHES. Each component is percent-encoded as a single opaque path segment.\n\n```go\nfunc (e Endpoints) Hostname() string\n```\nHostname returns e.Host with any port stripped, e.g. \"ghes.example.com:8443\" becomes \"ghes.example.com\". Host deliberately keeps a non-default port (see its doc comment) so IsHost can match a GHES instance reachable only on a non-default port; callers that need to compare against a portless value instead -- e.g. the host captured from an SCP-style Git remote (git@host:org/repo.git), which carries no port of its own -- use this instead of comparing against Host directly.\n\n```go\nfunc (e Endpoints) IsAPIHost(host string) bool\n```\nIsAPIHost reports whether host (case-insensitive, with port and trailing dot normalized) matches this Endpoints value's API host (derived from APIURL). This can differ from IsHost (ServerURL's host) for a corporate mirror that fronts the web/clone host and the API host separately, e.g. ATMOS\\_TOOLCHAIN\\_GITHUB\\_URL and ATMOS\\_TOOLCHAIN\\_GITHUB\\_API\\_URL pointing at different hosts. Callers that authenticate requests sent to APIURL (rather than ServerURL) should check this in addition to IsHost.\n\n```go\nfunc (e Endpoints) IsAPIHostForScheme(host, scheme string) bool\n```\nIsAPIHostForScheme is IsAPIHost's scheme-aware sibling (see normalizeHostForScheme). Callers deciding whether to attach a bearer/OAuth token to a request MUST use this instead of IsAPIHost.\n\n```go\nfunc (e Endpoints) IsHost(host string) bool\n```\nIsHost reports whether host (case-insensitive, with port and trailing dot normalized) matches this Endpoints value's own Host. It intentionally does not also match \"github.com\": callers that need to recognize both this endpoint's host and public github.com (e.g. because toolchain assets are always public even under GHES) combine IsHost with an explicit github.com check.\n\n```go\nfunc (e Endpoints) IsHostForScheme(host, scheme string) bool\n```\nIsHostForScheme is IsHost's scheme-aware sibling (see normalizeHostForScheme): it strips only the default port for scheme instead of unconditionally stripping both 80 and 443, so an explicit non-default port (e.g. \"host:80\" for a \"https\" request) never matches the bare configured host. Callers deciding whether to attach a bearer/OAuth token to a request -- where the scheme is already known -- MUST use this instead of IsHost.\n\n```go\nfunc (e Endpoints) IsUploadHost(host string) bool\n```\nIsUploadHost reports whether host (case-insensitive, with port and trailing dot normalized) matches this Endpoints value's upload host (derived from UploadURL). This can differ from both IsHost and IsAPIHost, e.g. on public github.com uploads go to the separate uploads.github.com host. Callers that authenticate requests sent for release-asset uploads should check this in addition to IsHost/IsAPIHost.\n\n```go\nfunc (e Endpoints) IsUploadHostForScheme(host, scheme string) bool\n```\nIsUploadHostForScheme is IsUploadHost's scheme-aware sibling (see normalizeHostForScheme). Callers deciding whether to attach a bearer/OAuth token to a request MUST use this instead of IsUploadHost.\n\n```go\nfunc (e Endpoints) RawURL(owner, repo, ref, path string) string\n```\nRawURL builds the URL for fetching a file's raw content at ref from owner/repo. On github.com this is raw.githubusercontent.com; on GitHub Enterprise Server, raw content is served from the same host under /raw/ instead of a separate subdomain. Path may be empty (returns the ref root) and any leading slash is stripped.\n\nOwner, repo, and ref are percent-encoded as single opaque path segments -- a \"/\" occurring within one of them (e.g. a malicious or malformed ref) is escaped as data (\"%2F\") rather than reinterpreted as an additional path separator. Path is a genuine multi-segment file path, so each \"/\"-separated segment is escaped independently instead.\n\n```go\nfunc (e Endpoints) ReleaseAssetURL(owner, repo, tag, asset string) string\n```\nReleaseAssetURL builds the URL for downloading a release asset. The path shape (\\`/\\\u003cowner\u003e/\\\u003crepo\u003e/releases/download/\\\u003ctag\u003e/\\\u003casset\u003e\\`) is identical on github.com and GHES. Each component is percent-encoded as a single opaque path segment.\n\n```go\ntype PRArtifactInfo struct {\n\t// PR number.\n\tPRNumber int\n\t// Head SHA of the PR.\n\tHeadSHA string\n\t// Workflow run ID that produced the artifact.\n\tRunID int64\n\t// Artifact ID.\n\tArtifactID int64\n\t// Artifact name (e.g., \"build-artifacts-macos\").\n\tArtifactName string\n\t// Size in bytes.\n\tSizeInBytes int64\n\t// Download URL. Downloads from public repositories work without authentication\n\t// (subject to rate limits); private repositories require a token.\n\tDownloadURL string\n\t// RunStartedAt is when the workflow run started.\n\tRunStartedAt time.Time\n}\n```\nPRArtifactInfo contains information about a PR's build artifact.\n\n```go\nfunc GetPRArtifactInfo(ctx context.Context, owner, repo string, prNumber int) (*PRArtifactInfo, error)\n```\nGetPRArtifactInfo retrieves build artifact information for a PR. This finds the latest successful workflow run for the PR and locates the artifact matching the current platform. Works without authentication for public repositories (subject to rate limits).\n\n```go\ntype PullRequestService interface {\n\tGet(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error)\n}\n```\nPullRequestService defines the interface for pull request operations. This allows for mocking in tests.\n\n```go\ntype RateLimitService interface {\n\tGet(ctx context.Context) (*github.RateLimits, *github.Response, error)\n}\n```\nRateLimitService defines the interface for rate limit operations. This allows for mocking in tests.\n\n```go\ntype RateLimitStatus struct {\n\t// Remaining is the number of requests remaining in the current rate limit window.\n\tRemaining int\n\t// Limit is the maximum number of requests allowed in the rate limit window.\n\tLimit int\n\t// ResetAt is when the rate limit will reset.\n\tResetAt time.Time\n}\n```\nRateLimitStatus contains information about GitHub API rate limits.\n\n```go\nfunc CheckRateLimit(ctx context.Context) (*RateLimitStatus, error)\n```\nCheckRateLimit queries the GitHub API for current rate limit status. Returns nil status (not error) if the check fails, to avoid blocking operations.\n\n```go\nfunc CheckRateLimitWithService(ctx context.Context, service RateLimitService) (*RateLimitStatus, error)\n```\nCheckRateLimitWithService queries the GitHub API using a custom service. This is primarily used for testing with mock services.\n\n```go\ntype ReleasesOptions struct {\n\tOwner              string\n\tRepo               string\n\tLimit              int\n\tOffset             int\n\tIncludePrereleases bool\n\tSince              *time.Time\n}\n```\nReleasesOptions contains options for fetching GitHub releases.\n\n```go\ntype RepositoriesService interface {\n\tGetCommitSHA1(ctx context.Context, owner, repo, ref, lastSHA string) (string, *github.Response, error)\n}\n```\nRepositoriesService defines the interface for repository operations. This allows for mocking in tests.\n\n```go\ntype RepositoryHealth struct {\n\tStatus  string\n\tMessage string\n}\n```\nRepositoryHealth retains uncertainty: GitHub hides private repositories behind 404s.\n\n```go\nfunc InspectRepository(ctx context.Context, gitURI string) RepositoryHealth\n```\nInspectRepository checks repository metadata without cloning or resolving versions. Tokens retain the existing host/scheme scoping used by other GitHub operations.\n\n```go\ntype SHAArtifactInfo struct {\n\t// Head SHA of the commit.\n\tHeadSHA string\n\t// Workflow run ID that produced the artifact.\n\tRunID int64\n\t// Artifact ID.\n\tArtifactID int64\n\t// Artifact name (e.g., \"build-artifacts-macos\").\n\tArtifactName string\n\t// Size in bytes.\n\tSizeInBytes int64\n\t// Download URL. Downloads from public repositories work without authentication\n\t// (subject to rate limits); private repositories require a token.\n\tDownloadURL string\n\t// RunStartedAt is when the workflow run started.\n\tRunStartedAt time.Time\n}\n```\nSHAArtifactInfo contains information about a SHA's build artifact.\n\n```go\nfunc GetSHAArtifactInfo(ctx context.Context, owner, repo, sha string) (*SHAArtifactInfo, error)\n```\nGetSHAArtifactInfo retrieves build artifact information for a commit SHA. This finds the latest successful workflow run for the SHA and locates the artifact matching the current platform. Works without authentication for public repositories (subject to rate limits).\n\n","path":"github.com/cloudposse/atmos/pkg/github","name":"github","synopsis":"","isRedistributable":true}
