Skip to content

Commit c098b25

Browse files
committed
Only upload upload-sarif debug artifacts at most once
Previously, we uploaded combined SARIF artifacts in both the `analyze-post` and `upload-sarif-post` steps. This change ensures that these artifacts are uploaded at most once — in `analyze-post` if it is a first-party run and `upload-sarif-post` if it is a third-party run. This is a defensive check because as we upgrade to the new `artifact` dependencies we will not be able to upload artifacts to the same artifact directory.
1 parent b296f26 commit c098b25

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/analyze-action-post.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ import * as core from "@actions/core";
77

88
import * as analyzeActionPostHelper from "./analyze-action-post-helper";
99
import * as debugArtifacts from "./debug-artifacts";
10+
import { EnvVar } from "./environment";
1011
import * as uploadSarifActionPostHelper from "./upload-sarif-action-post-helper";
1112
import { wrapError } from "./util";
1213

1314
async function runWrapper() {
1415
try {
1516
await analyzeActionPostHelper.run();
1617

17-
// Also run the upload-sarif post action since we're potentially running
18-
// the same steps in the analyze action.
19-
await uploadSarifActionPostHelper.uploadArtifacts(
20-
debugArtifacts.uploadDebugArtifacts,
21-
);
18+
// Upload SARIF artifacts if we determine that this is a first-party analysis run.
19+
// For third-party runs, this artifact will be uploaded in the `upload-sarif-post` step.
20+
if (process.env[EnvVar.INIT_ACTION_HAS_RUN] === "true") {
21+
await uploadSarifActionPostHelper.uploadArtifacts(
22+
debugArtifacts.uploadDebugArtifacts,
23+
);
24+
}
2225
} catch (error) {
2326
core.setFailed(
2427
`analyze post-action step failed: ${wrapError(error).message}`,

src/upload-sarif-action-post.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
import * as core from "@actions/core";
77

88
import * as debugArtifacts from "./debug-artifacts";
9+
import { EnvVar } from "./environment";
910
import * as uploadSarifActionPostHelper from "./upload-sarif-action-post-helper";
1011
import { wrapError } from "./util";
1112

1213
async function runWrapper() {
1314
try {
14-
await uploadSarifActionPostHelper.uploadArtifacts(
15-
debugArtifacts.uploadDebugArtifacts,
16-
);
15+
// Upload SARIF artifacts if we determine that this is a third-party analysis run.
16+
// For first-party runs, this artifact will be uploaded in the `analyze-post` step.
17+
if (process.env[EnvVar.INIT_ACTION_HAS_RUN] !== "true") {
18+
await uploadSarifActionPostHelper.uploadArtifacts(
19+
debugArtifacts.uploadDebugArtifacts,
20+
);
21+
}
1722
} catch (error) {
1823
core.setFailed(
1924
`upload-sarif post-action step failed: ${wrapError(error).message}`,

0 commit comments

Comments
 (0)