From 989d6f4689b2f2c82d54b4a98e9023e1705d6408 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 10 Apr 2026 17:29:36 +0100 Subject: [PATCH] Move `CODEQL_ACTION_REPO` out of `sync-checks.ts` --- pr-checks/api-client.ts | 6 ++++++ pr-checks/sync-checks.ts | 15 +++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pr-checks/api-client.ts b/pr-checks/api-client.ts index 2622515d0..95a7f8916 100644 --- a/pr-checks/api-client.ts +++ b/pr-checks/api-client.ts @@ -5,6 +5,12 @@ import { type Octokit } from "@octokit/core"; import { type PaginateInterface } from "@octokit/plugin-paginate-rest"; import { type Api } from "@octokit/plugin-rest-endpoint-methods"; +/** Identifies the CodeQL Action repository. */ +export const CODEQL_ACTION_REPO = { + owner: "github", + repo: "codeql-action", +}; + /** The type of the Octokit client. */ export type ApiClient = Octokit & Api & { paginate: PaginateInterface }; diff --git a/pr-checks/sync-checks.ts b/pr-checks/sync-checks.ts index ab9d237ca..ae8a166a8 100755 --- a/pr-checks/sync-checks.ts +++ b/pr-checks/sync-checks.ts @@ -9,6 +9,7 @@ import * as yaml from "yaml"; import { type ApiClient, + CODEQL_ACTION_REPO, getApiClient, TOKEN_OPTION_CONFIG, TokenOption, @@ -28,12 +29,6 @@ export interface Options extends TokenOption { verbose: boolean; } -/** Identifies the CodeQL Action repository. */ -const codeqlActionRepo = { - owner: "github", - repo: "codeql-action", -}; - /** Represents a configuration of which checks should not be set up as required checks. */ export interface Exclusions { /** A list of strings that, if contained in a check name, are excluded. */ @@ -103,7 +98,7 @@ async function getChecksFor( const response = await client.paginate( "GET /repos/{owner}/{repo}/commits/{ref}/check-runs", { - ...codeqlActionRepo, + ...CODEQL_ACTION_REPO, ref, }, ); @@ -136,7 +131,7 @@ async function getChecksFor( /** Gets the current list of release branches. */ async function getReleaseBranches(client: ApiClient): Promise { const refs = await client.rest.git.listMatchingRefs({ - ...codeqlActionRepo, + ...CODEQL_ACTION_REPO, ref: "heads/releases/v", }); return refs.data.map((ref) => ref.ref).sort(); @@ -149,7 +144,7 @@ async function patchBranchProtectionRule( checks: Set, ) { await client.rest.repos.setStatusCheckContexts({ - ...codeqlActionRepo, + ...CODEQL_ACTION_REPO, branch, contexts: Array.from(checks), }); @@ -166,7 +161,7 @@ async function updateBranch( // Query the current set of required checks for this branch. const currentContexts = await client.rest.repos.getAllStatusCheckContexts({ - ...codeqlActionRepo, + ...CODEQL_ACTION_REPO, branch, });