Skip to content

Commit 98f7bbd

Browse files
authored
Add workflow_run_attempt data to status report (#1640)
1 parent d7b9dcd commit 98f7bbd

7 files changed

+23
-9
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [UNRELEASED]
44

5-
No user facing changes.
5+
- Include the value of the `GITHUB_RUN_ATTEMPT` environment variable in the telemetry sent to GitHub. [#1640](https://github.com/github/codeql-action/pull/1640)
66

77
## 2.2.11 - 06 Apr 2023
88

lib/actions-util.js

+6
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

+3-3
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.

src/actions-util.ts

+8
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ export type ActionStatus =
313313
export interface StatusReportBase {
314314
/** ID of the workflow run containing the action run. */
315315
workflow_run_id: number;
316+
/** Attempt number of the run containing the action run. */
317+
workflow_run_attempt: number;
316318
/** Workflow name. Converted to analysis_name further down the pipeline.. */
317319
workflow_name: string;
318320
/** Job name from the workflow. */
@@ -410,6 +412,11 @@ export async function createStatusReportBase(
410412
if (workflowRunIDStr) {
411413
workflowRunID = parseInt(workflowRunIDStr, 10);
412414
}
415+
const workflowRunAttemptStr = process.env["GITHUB_RUN_ATTEMPT"];
416+
let workflowRunAttempt = -1;
417+
if (workflowRunAttemptStr) {
418+
workflowRunAttempt = parseInt(workflowRunAttemptStr, 10);
419+
}
413420
const workflowName = process.env["GITHUB_WORKFLOW"] || "";
414421
const jobName = process.env["GITHUB_JOB"] || "";
415422
const analysis_key = await getAnalysisKey();
@@ -437,6 +444,7 @@ export async function createStatusReportBase(
437444

438445
const statusReport: StatusReportBase = {
439446
workflow_run_id: workflowRunID,
447+
workflow_run_attempt: workflowRunAttempt,
440448
workflow_name: workflowName,
441449
job_name: jobName,
442450
analysis_key,

src/util.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ export function assertNever(value: never): never {
438438
* knowing what version of CodeQL we're running.
439439
*/
440440
export function initializeEnvironment(version: string) {
441-
core.exportVariable(EnvVar.VERSION, version);
442-
core.exportVariable(EnvVar.FEATURE_SARIF_COMBINE, "true");
443-
core.exportVariable(EnvVar.FEATURE_WILL_UPLOAD, "true");
441+
core.exportVariable(String(EnvVar.VERSION), version);
442+
core.exportVariable(String(EnvVar.FEATURE_SARIF_COMBINE), "true");
443+
core.exportVariable(String(EnvVar.FEATURE_WILL_UPLOAD), "true");
444444
}
445445

446446
/**

0 commit comments

Comments
 (0)