mirror of
https://github.com/github/codeql-action.git
synced 2026-01-01 20:20:07 +08:00
Prompt customers to upgrade from v1 to v2
This commit is contained in:
43
src/util.ts
43
src/util.ts
@@ -7,6 +7,7 @@ import * as core from "@actions/core";
|
||||
import del from "del";
|
||||
import * as semver from "semver";
|
||||
|
||||
import * as api from "./api-client";
|
||||
import { getApiClient, GitHubApiDetails } from "./api-client";
|
||||
import * as apiCompatibility from "./api-compatibility.json";
|
||||
import { CodeQL, CODEQL_VERSION_NEW_TRACING } from "./codeql";
|
||||
@@ -708,3 +709,45 @@ export function getMlPoweredJsQueriesStatus(config: Config): string {
|
||||
return "other";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the customer to upgrade to CodeQL Action v2, if appropriate.
|
||||
*
|
||||
* Check whether a customer is running v1. If they are, and we can determine that the GitHub
|
||||
* instance supports v2, then log a warning about v1's upcoming deprecation prompting the customer
|
||||
* to upgrade to v2.
|
||||
*/
|
||||
export async function checkActionVersion(version: string) {
|
||||
if (!semver.satisfies(version, ">=2")) {
|
||||
const githubVersion = await api.getGitHubVersionActionsOnly();
|
||||
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 2.
|
||||
if (
|
||||
githubVersion.type === GitHubVariant.DOTCOM ||
|
||||
githubVersion.type === GitHubVariant.GHAE ||
|
||||
(githubVersion.type === GitHubVariant.GHES &&
|
||||
semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.4"
|
||||
))
|
||||
) {
|
||||
core.warning(
|
||||
"CodeQL Action version 1 will be deprecated on December 7th, 2022. Please upgrade to " +
|
||||
"version 2. For more information, see " +
|
||||
"https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function formatGitHubVersion(version: GitHubVersion): string {
|
||||
switch (version.type) {
|
||||
case GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case GitHubVariant.GHAE:
|
||||
return "GHAE";
|
||||
case GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
assertNever(version);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user