Skip to content

Commit f8bd51a

Browse files
committed
Favor GITHUB_WORKFLOW_REF
Introduced with GHES 3.9: https://docs.github.com/en/enterprise-server@3.9/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.
1 parent c79c360 commit f8bd51a

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the
88

99
- Update default CodeQL bundle version to 2.16.2. [#2124](https://github.com/github/codeql-action/pull/2124)
1010
- 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)
11+
- Users of GHES3.9+ and GHEC will no longer need to include `actions: read` permissions to use `upload-sarif` in private repositories.
1112

1213
## 3.24.0 - 02 Feb 2024
1314

lib/api-client.js

Lines changed: 10 additions & 0 deletions
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ export async function getGitHubVersion(): Promise<GitHubVersion> {
119119
* Get the path of the currently executing workflow relative to the repository root.
120120
*/
121121
export async function getWorkflowRelativePath(): Promise<string> {
122+
const workflow_ref = process.env["GITHUB_WORKFLOW_REF"];
123+
if (workflow_ref !== undefined) {
124+
const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*");
125+
const match = workflow_ref.match(workflowRegExp);
126+
if (match) {
127+
return new Promise((resolve) => {
128+
resolve(match[1]);
129+
});
130+
}
131+
}
122132
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
123133
const owner = repo_nwo[0];
124134
const repo = repo_nwo[1];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy