Skip to content

Commit

Permalink
Update workflow path for default setup
Browse files Browse the repository at this point in the history
In default setup, the workflow is not checked into the repository.
Instead it exists at a fixed path.
  • Loading branch information
henrymercer committed Mar 28, 2023
1 parent f9c159f commit 6bd6528
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/actions-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/workflow.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/workflow.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getCodeQLDatabasePath,
getRequiredEnvParam,
GITHUB_DOTCOM_URL,
isDefaultSetup,
isHTTPError,
isInTestMode,
parseMatrixInput,
Expand Down Expand Up @@ -573,8 +574,8 @@ 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") {
// For default setup, `CODESCANNING_EVENT_NAME` will contain the right info (push/pull_request).
if (isDefaultSetup()) {
const value = process.env["CODESCANNING_EVENT_NAME"];
if (value === undefined || value.length === 0) {
return process.env["GITHUB_EVENT_NAME"];
Expand Down
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,3 +888,7 @@ export function fixInvalidNotificationsInFile(
sarif = fixInvalidNotifications(sarif, logger);
fs.writeFileSync(outputPath, JSON.stringify(sarif));
}

export function isDefaultSetup(): boolean {
return process.env["GITHUB_EVENT_NAME"] === "dynamic";
}
8 changes: 7 additions & 1 deletion src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as core from "@actions/core";
import * as yaml from "js-yaml";

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

export interface WorkflowJobStep {
name?: string;
Expand Down Expand Up @@ -276,6 +276,12 @@ export async function getWorkflow(): Promise<Workflow> {
* Get the path of the currently executing workflow.
*/
export async function getWorkflowPath(): Promise<string> {
if (isDefaultSetup()) {
// In default setup, the workflow file is not checked into the repository. Instead it exists at
// this fixed path.
return "dynamic/github-code-scanning/codeql";
}

const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
const owner = repo_nwo[0];
const repo = repo_nwo[1];
Expand Down

0 comments on commit 6bd6528

Please sign in to comment.