Skip to content

Commit 989d6f4

Browse files
committed
Move CODEQL_ACTION_REPO out of sync-checks.ts
1 parent dbfd510 commit 989d6f4

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pr-checks/api-client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { type Octokit } from "@octokit/core";
55
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
66
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
77

8+
/** Identifies the CodeQL Action repository. */
9+
export const CODEQL_ACTION_REPO = {
10+
owner: "github",
11+
repo: "codeql-action",
12+
};
13+
814
/** The type of the Octokit client. */
915
export type ApiClient = Octokit & Api & { paginate: PaginateInterface };
1016

pr-checks/sync-checks.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as yaml from "yaml";
99

1010
import {
1111
type ApiClient,
12+
CODEQL_ACTION_REPO,
1213
getApiClient,
1314
TOKEN_OPTION_CONFIG,
1415
TokenOption,
@@ -28,12 +29,6 @@ export interface Options extends TokenOption {
2829
verbose: boolean;
2930
}
3031

31-
/** Identifies the CodeQL Action repository. */
32-
const codeqlActionRepo = {
33-
owner: "github",
34-
repo: "codeql-action",
35-
};
36-
3732
/** Represents a configuration of which checks should not be set up as required checks. */
3833
export interface Exclusions {
3934
/** A list of strings that, if contained in a check name, are excluded. */
@@ -103,7 +98,7 @@ async function getChecksFor(
10398
const response = await client.paginate(
10499
"GET /repos/{owner}/{repo}/commits/{ref}/check-runs",
105100
{
106-
...codeqlActionRepo,
101+
...CODEQL_ACTION_REPO,
107102
ref,
108103
},
109104
);
@@ -136,7 +131,7 @@ async function getChecksFor(
136131
/** Gets the current list of release branches. */
137132
async function getReleaseBranches(client: ApiClient): Promise<string[]> {
138133
const refs = await client.rest.git.listMatchingRefs({
139-
...codeqlActionRepo,
134+
...CODEQL_ACTION_REPO,
140135
ref: "heads/releases/v",
141136
});
142137
return refs.data.map((ref) => ref.ref).sort();
@@ -149,7 +144,7 @@ async function patchBranchProtectionRule(
149144
checks: Set<string>,
150145
) {
151146
await client.rest.repos.setStatusCheckContexts({
152-
...codeqlActionRepo,
147+
...CODEQL_ACTION_REPO,
153148
branch,
154149
contexts: Array.from(checks),
155150
});
@@ -166,7 +161,7 @@ async function updateBranch(
166161

167162
// Query the current set of required checks for this branch.
168163
const currentContexts = await client.rest.repos.getAllStatusCheckContexts({
169-
...codeqlActionRepo,
164+
...CODEQL_ACTION_REPO,
170165
branch,
171166
});
172167

0 commit comments

Comments
 (0)