Skip to content

Commit d1b97ac

Browse files
committed
Move GitHubApiDetails to github.ts
1 parent cdb2530 commit d1b97ac

2 files changed

Lines changed: 41 additions & 35 deletions

File tree

‎src/api-client.ts‎

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import {
1919
getEnv,
2020
exportEnvVar,
2121
} from "./environment";
22-
import { GITHUB_DOTCOM_URL, parseGitHubUrl } from "./github";
22+
import {
23+
GITHUB_DOTCOM_URL,
24+
parseGitHubUrl,
25+
type GitHubApiCombinedDetails,
26+
type GitHubApiDetails,
27+
} from "./github";
2328
import { Logger } from "./logging";
2429
import { getRepositoryNwo, RepositoryNwo } from "./repository";
2530
import {
@@ -31,6 +36,8 @@ import {
3136
parseMatrixInput,
3237
} from "./util";
3338

39+
export type { GitHubApiDetails, GitHubApiCombinedDetails } from "./github";
40+
3441
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
3542

3643
/**
@@ -42,39 +49,6 @@ const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
4249
*/
4350
export const DO_NOT_RETRY_STATUSES = [400, 410, 422, 451];
4451

45-
/**
46-
* Represents information about a GitHub instance, how to authenticate to it,
47-
* and how to authenticate to other repos on it.
48-
*/
49-
export type GitHubApiCombinedDetails = GitHubApiDetails &
50-
GitHubApiExternalRepoDetails;
51-
52-
/** Represents information about a GitHub instance. */
53-
export type GitHubInstance = {
54-
/** The base URL of the GitHub instance, such as `https://github.com`. */
55-
url: string;
56-
/**
57-
* The API base URL of the GitHub instance, such as `https://api.github.com`.
58-
* Typically this is the `api.` subdomain of the `url` domain.
59-
*/
60-
apiURL: string | undefined;
61-
};
62-
63-
/** Represents a {@link GitHubInstance} with a token for accessing the API. */
64-
export type GitHubApiDetails = GitHubInstance & {
65-
/** The token to use for accessing the API of the GitHub instance. */
66-
auth: string;
67-
};
68-
69-
/**
70-
* Represents information for accessing a repository on the same GitHub instance as the Action
71-
* is currently running on.
72-
*/
73-
export type GitHubApiExternalRepoDetails = {
74-
/** An optional token for accessing repo(s) on the same GitHub instance. */
75-
externalRepoAuth?: string;
76-
};
77-
7852
/**
7953
* Gets the configuration for the private registry authentication proxy,
8054
* if it is available in the environment.

‎src/github.ts‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { GitHubInstance } from "./api-client";
21
import { ActionsEnvVars, type ReadOnlyEnv } from "./environment";
32
import { ConfigurationError } from "./util";
43

@@ -18,6 +17,39 @@ export type InstanceApiURL = string;
1817
*/
1918
export const GITHUB_DOTCOM_API_URL: InstanceApiURL = "https://api.github.com";
2019

20+
/**
21+
* Represents information about a GitHub instance, how to authenticate to it,
22+
* and how to authenticate to other repos on it.
23+
*/
24+
export type GitHubApiCombinedDetails = GitHubApiDetails &
25+
GitHubApiExternalRepoDetails;
26+
27+
/** Represents information about a GitHub instance. */
28+
export type GitHubInstance = {
29+
/** The base URL of the GitHub instance, such as `https://github.com`. */
30+
url: string;
31+
/**
32+
* The API base URL of the GitHub instance, such as `https://api.github.com`.
33+
* Typically this is the `api.` subdomain of the `url` domain.
34+
*/
35+
apiURL: string | undefined;
36+
};
37+
38+
/** Represents a {@link GitHubInstance} with a token for accessing the API. */
39+
export type GitHubApiDetails = GitHubInstance & {
40+
/** The token to use for accessing the API of the GitHub instance. */
41+
auth: string;
42+
};
43+
44+
/**
45+
* Represents information for accessing a repository on the same GitHub instance as the Action
46+
* is currently running on.
47+
*/
48+
export type GitHubApiExternalRepoDetails = {
49+
/** An optional token for accessing repo(s) on the same GitHub instance. */
50+
externalRepoAuth?: string;
51+
};
52+
2153
/**
2254
* Parses user input of a github.com or GHES URL to a canonical form.
2355
* Removes any API prefix or suffix if one is present.

0 commit comments

Comments
 (0)