File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ import {
1818 RegistryProxyVars ,
1919 getEnv ,
2020 exportEnvVar ,
21+ ActionsEnvVars ,
2122} from "./environment" ;
2223import {
2324 getCurrentInstance ,
25+ getDotcomInstance ,
2426 GITHUB_DOTCOM_URL ,
2527 parseGitHubUrl ,
2628 type GitHubApiCombinedDetails ,
@@ -187,6 +189,28 @@ export function getApiClient(
187189 return createApiClientWithDetails ( apiDetails ?? getApiDetails ( env ) ) ;
188190}
189191
192+ /*
193+ * Gets a `GitHubApiDetails` object describing the GitHub Dotcom instance.
194+ *
195+ * @param env The environment variables to read.
196+ */
197+ export function getDotcomApiDetails ( env : ReadOnlyEnv ) : GitHubApiDetails {
198+ // If we are currently running on dotcom, then just call `getApiDetails` which will
199+ // construct the appropriate `GitHubApiDetails` from the environment and include the
200+ // value of the `token` input. The `token` input relates to the GitHub instance that
201+ // we are running on only. Therefore, if we are not currently running on dotcom,
202+ // then we construct `GitHubApiDetails` without the `token` value and using the
203+ // hard-coded instance and API URLs.
204+ if ( env . getRequired ( ActionsEnvVars . GITHUB_SERVER_URL ) === GITHUB_DOTCOM_URL ) {
205+ return getApiDetails ( env ) ;
206+ } else {
207+ return {
208+ auth : undefined ,
209+ ...getDotcomInstance ( ) ,
210+ } ;
211+ }
212+ }
213+
190214export function getApiClientWithExternalAuth (
191215 apiDetails : GitHubApiCombinedDetails ,
192216 proxy ?: ProxyAgent ,
You can’t perform that action at this time.
0 commit comments