Skip to content

Commit

Permalink
Favor GITHUB_WORKFLOW_REF
Browse files Browse the repository at this point in the history
Introduced with GHES 3.9:
https://docs.github.com/en/[email protected]/actions/learn-github-actions/variables

GITHUB_WORKFLOW_REF means that actions don't need to use `actions: read`
to determine the path to the running workflow.
  • Loading branch information
jsoref committed Feb 13, 2024
1 parent c79c360 commit f8bd51a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the

- Update default CodeQL bundle version to 2.16.2. [#2124](https://github.com/github/codeql-action/pull/2124)
- The CodeQL action no longer fails if it can't write to the telemetry api endpoint. [#2121](https://github.com/github/codeql-action/pull/2121)
- Users of GHES3.9+ and GHEC will no longer need to include `actions: read` permissions to use `upload-sarif` in private repositories.

## 3.24.0 - 02 Feb 2024

Expand Down
10 changes: 10 additions & 0 deletions lib/api-client.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/api-client.js.map

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

10 changes: 10 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ export async function getGitHubVersion(): Promise<GitHubVersion> {
* Get the path of the currently executing workflow relative to the repository root.
*/
export async function getWorkflowRelativePath(): Promise<string> {
const workflow_ref = process.env["GITHUB_WORKFLOW_REF"];
if (workflow_ref !== undefined) {
const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*");
const match = workflow_ref.match(workflowRegExp);
if (match) {
return new Promise((resolve) => {
resolve(match[1]);
});
}
}
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
const owner = repo_nwo[0];
const repo = repo_nwo[1];
Expand Down

0 comments on commit f8bd51a

Please sign in to comment.