mirror of
https://github.com/github/codeql-action.git
synced 2026-04-30 10:50:14 +00:00
Move CODEQL_ACTION_REPO out of sync-checks.ts
This commit is contained in:
@@ -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 };
|
||||
|
||||
|
||||
@@ -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<string[]> {
|
||||
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<string>,
|
||||
) {
|
||||
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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user