mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 09:40:17 +08:00
Remove unused CODESCANNING_EVENT_NAME environment variable
This commit is contained in:
@@ -214,6 +214,7 @@ test("initializeEnvironment", (t) => {
|
||||
});
|
||||
|
||||
test("isAnalyzingDefaultBranch()", async (t) => {
|
||||
process.env["GITHUB_EVENT_NAME"] = "push";
|
||||
process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "true";
|
||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
|
||||
process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "false";
|
||||
@@ -264,14 +265,3 @@ test("isAnalyzingDefaultBranch()", async (t) => {
|
||||
getAdditionalInputStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
test("workflowEventName()", async (t) => {
|
||||
process.env["GITHUB_EVENT_NAME"] = "push";
|
||||
t.deepEqual(actionsutil.workflowEventName(), "push");
|
||||
|
||||
process.env["GITHUB_EVENT_NAME"] = "dynamic";
|
||||
t.deepEqual(actionsutil.workflowEventName(), "dynamic");
|
||||
|
||||
process.env["CODESCANNING_EVENT_NAME"] = "push";
|
||||
t.deepEqual(actionsutil.workflowEventName(), "push");
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ export const getCommitOid = async function (
|
||||
export const determineMergeBaseCommitOid = async function (): Promise<
|
||||
string | undefined
|
||||
> {
|
||||
if (workflowEventName() !== "pull_request") {
|
||||
if (getWorkflowEventName() !== "pull_request") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -576,21 +576,18 @@ export async function sendStatusReport<S extends StatusReportBase>(
|
||||
}
|
||||
}
|
||||
|
||||
export function workflowEventName() {
|
||||
// If the original event is dynamic CODESCANNING_EVENT_NAME will contain the right info (push/pull_request)
|
||||
if (process.env["GITHUB_EVENT_NAME"] === "dynamic") {
|
||||
const value = process.env["CODESCANNING_EVENT_NAME"];
|
||||
if (value === undefined || value.length === 0) {
|
||||
return process.env["GITHUB_EVENT_NAME"];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return process.env["GITHUB_EVENT_NAME"];
|
||||
/**
|
||||
* Returns the name of the event that triggered this workflow.
|
||||
*
|
||||
* This will be "dynamic" for default setup workflow runs.
|
||||
*/
|
||||
export function getWorkflowEventName() {
|
||||
return getRequiredEnvParam("GITHUB_EVENT_NAME");
|
||||
}
|
||||
|
||||
// Was the workflow run triggered by a `push` event, for example as opposed to a `pull_request` event.
|
||||
function workflowIsTriggeredByPushEvent() {
|
||||
return workflowEventName() === "push";
|
||||
return getWorkflowEventName() === "push";
|
||||
}
|
||||
|
||||
// Is dependabot the actor that triggered the current workflow run.
|
||||
@@ -647,7 +644,7 @@ export async function isAnalyzingDefaultBranch(): Promise<boolean> {
|
||||
const event = getWorkflowEvent();
|
||||
let defaultBranch = event?.repository?.default_branch;
|
||||
|
||||
if (process.env.GITHUB_EVENT_NAME === "schedule") {
|
||||
if (getWorkflowEventName() === "schedule") {
|
||||
defaultBranch = removeRefsHeadsPrefix(getRequiredEnvParam("GITHUB_REF"));
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ export async function downloadTrapCaches(
|
||||
let baseSha = "unknown";
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
||||
if (
|
||||
actionsUtil.workflowEventName() === "pull_request" &&
|
||||
actionsUtil.getWorkflowEventName() === "pull_request" &&
|
||||
eventPath !== undefined
|
||||
) {
|
||||
const event = JSON.parse(fs.readFileSync(path.resolve(eventPath), "utf-8"));
|
||||
|
||||
@@ -293,7 +293,7 @@ export function buildPayload(
|
||||
base_sha: undefined as undefined | string,
|
||||
};
|
||||
|
||||
if (actionsUtil.workflowEventName() === "pull_request") {
|
||||
if (actionsUtil.getWorkflowEventName() === "pull_request") {
|
||||
if (
|
||||
commitOid === util.getRequiredEnvParam("GITHUB_SHA") &&
|
||||
mergeBaseCommitOid
|
||||
|
||||
Reference in New Issue
Block a user