Skip to content

Commit 1a4385d

Browse files
committed
Only log the version warning once on Actions even if the Action is invoked multiple times.
1 parent 865b4bd commit 1a4385d

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/api-client.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from "path";
22

3+
import { exportVariable } from "@actions/core";
34
import * as githubUtils from "@actions/github/lib/utils";
45
import * as retry from "@octokit/plugin-retry";
56
import { OctokitResponse } from "@octokit/types";
@@ -17,6 +18,8 @@ export enum DisallowedAPIVersionReason {
1718
}
1819

1920
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
21+
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
22+
"CODEQL_ACTION_WARNED_ABOUT_VERSION";
2023
let hasBeenWarnedAboutVersion = false;
2124

2225
export const getApiClient = function (
@@ -33,7 +36,8 @@ export const getApiClient = function (
3336
octokit.hook.after("request", (response: OctokitResponse<any>, _) => {
3437
if (
3538
!hasBeenWarnedAboutVersion &&
36-
response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] !== undefined
39+
response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] !== undefined &&
40+
process.env[CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR] !== undefined
3741
) {
3842
const installedVersion = response.headers[
3943
GITHUB_ENTERPRISE_VERSION_HEADER
@@ -63,6 +67,9 @@ export const getApiClient = function (
6367
);
6468
}
6569
hasBeenWarnedAboutVersion = true;
70+
if (mode === "actions") {
71+
exportVariable(CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR, true);
72+
}
6673
}
6774
});
6875
});

0 commit comments

Comments
 (0)