Skip to content

Commit da44c92

Browse files
committed
Initialise API client
1 parent c9e3173 commit da44c92

File tree

3 files changed

+55
-30
lines changed

3 files changed

+55
-30
lines changed

package-lock.json

Lines changed: 34 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pr-checks/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
},
77
"devDependencies": {
88
"@actions/core": "*",
9+
"@actions/github": "*",
10+
"@octokit/core": "*",
11+
"@octokit/plugin-paginate-rest": "*",
12+
"@octokit/plugin-rest-endpoint-methods": "*",
913
"@types/node": "^20.19.9",
1014
"tsx": "^4.21.0",
1115
"typescript": "^5.9.3"

pr-checks/sync-checks.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44

55
import { parseArgs } from "node:util";
66

7+
import * as githubUtils from "@actions/github/lib/utils";
8+
import { type Octokit } from "@octokit/core";
9+
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
10+
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
11+
712
import { OLDEST_SUPPORTED_MAJOR_VERSION } from "./config";
813

14+
/** The type of the Octokit client. */
15+
type ApiClient = Octokit & Api & { paginate: PaginateInterface };
16+
17+
/** Constructs an `ApiClient` using `token` for authentication. */
18+
function getApiClient(token: string): ApiClient {
19+
const opts = githubUtils.getOctokitOptions(token);
20+
return new githubUtils.GitHub(opts);
21+
}
22+
923
async function main(): Promise<void> {
1024
const { values: options } = parseArgs({
1125
options: {
@@ -37,6 +51,9 @@ async function main(): Promise<void> {
3751
`Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`,
3852
);
3953

54+
// Initialise the API client.
55+
const client = getApiClient(options.token);
56+
4057
process.exit(0);
4158
}
4259

0 commit comments

Comments
 (0)