Add functions to get the current and dotcom instance

This commit is contained in:
Michael B. Gale
2026-10-13 14:48:24 +01:00
parent 102e46e9d1
commit 61bfcffab9
2 changed files with 59 additions and 1 deletions

View File

@@ -60,3 +60,19 @@ export function parseGitHubUrl(inputUrl: string): string {
return url.toString();
}
/** Retrieves a {@link GitHubInstance} describing the instance we are running on. */
export function getCurrentInstance(env: ReadOnlyEnv): GitHubInstance {
return {
url: env.getRequired(ActionsEnvVars.GITHUB_SERVER_URL),
apiURL: env.getRequired(ActionsEnvVars.GITHUB_API_URL),
};
}
/** Retrieves a {@link GitHubInstance} describing the GitHub.com instance. */
export function getDotcomInstance(): GitHubInstance {
return {
url: GITHUB_DOTCOM_URL,
apiURL: GITHUB_DOTCOM_API_URL,
};
}