Skip to content

Commit 6bd6528

Browse files
committed
Update workflow path for default setup
In default setup, the workflow is not checked into the repository. Instead it exists at a fixed path.
1 parent f9c159f commit 6bd6528

9 files changed

+29
-9
lines changed

lib/actions-util.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/workflow.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/workflow.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getCodeQLDatabasePath,
1717
getRequiredEnvParam,
1818
GITHUB_DOTCOM_URL,
19+
isDefaultSetup,
1920
isHTTPError,
2021
isInTestMode,
2122
parseMatrixInput,
@@ -573,8 +574,8 @@ export async function sendStatusReport<S extends StatusReportBase>(
573574
}
574575

575576
export function workflowEventName() {
576-
// If the original event is dynamic CODESCANNING_EVENT_NAME will contain the right info (push/pull_request)
577-
if (process.env["GITHUB_EVENT_NAME"] === "dynamic") {
577+
// For default setup, `CODESCANNING_EVENT_NAME` will contain the right info (push/pull_request).
578+
if (isDefaultSetup()) {
578579
const value = process.env["CODESCANNING_EVENT_NAME"];
579580
if (value === undefined || value.length === 0) {
580581
return process.env["GITHUB_EVENT_NAME"];

src/util.ts

+4
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,7 @@ export function fixInvalidNotificationsInFile(
888888
sarif = fixInvalidNotifications(sarif, logger);
889889
fs.writeFileSync(outputPath, JSON.stringify(sarif));
890890
}
891+
892+
export function isDefaultSetup(): boolean {
893+
return process.env["GITHUB_EVENT_NAME"] === "dynamic";
894+
}

src/workflow.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as core from "@actions/core";
55
import * as yaml from "js-yaml";
66

77
import * as api from "./api-client";
8-
import { getRequiredEnvParam } from "./util";
8+
import { getRequiredEnvParam, isDefaultSetup } from "./util";
99

1010
export interface WorkflowJobStep {
1111
name?: string;
@@ -276,6 +276,12 @@ export async function getWorkflow(): Promise<Workflow> {
276276
* Get the path of the currently executing workflow.
277277
*/
278278
export async function getWorkflowPath(): Promise<string> {
279+
if (isDefaultSetup()) {
280+
// In default setup, the workflow file is not checked into the repository. Instead it exists at
281+
// this fixed path.
282+
return "dynamic/github-code-scanning/codeql";
283+
}
284+
279285
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
280286
const owner = repo_nwo[0];
281287
const repo = repo_nwo[1];

0 commit comments

Comments
 (0)