Skip to content

Commit a2ce099

Browse files
committed
Use findAndUpload for Code Scanning
1 parent 696b467 commit a2ce099

File tree

2 files changed

+41
-54
lines changed

2 files changed

+41
-54
lines changed

lib/upload-sarif-action.js

Lines changed: 21 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-sarif-action.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,18 @@ async function run() {
145145
throw new ConfigurationError(`Path does not exist: ${sarifPath}.`);
146146
}
147147

148-
const uploadResult = await upload_lib.uploadFiles(
148+
const uploadResult = await findAndUpload(
149+
logger,
150+
features,
149151
sarifPath,
152+
pathStats,
150153
checkoutPath,
151-
category,
152-
features,
153-
logger,
154154
analyses.CodeScanning,
155+
category,
155156
);
156-
core.setOutput("sarif-id", uploadResult.sarifID);
157+
if (uploadResult !== undefined) {
158+
core.setOutput("sarif-id", uploadResult.sarifID);
159+
}
157160

158161
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
159162
// Code quality can currently only be enabled on top of security, so we'd currently always expect to
@@ -172,15 +175,21 @@ async function run() {
172175
if (isInTestMode()) {
173176
core.debug("In test mode. Waiting for processing is disabled.");
174177
} else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
175-
await upload_lib.waitForProcessing(
176-
getRepositoryNwo(),
177-
uploadResult.sarifID,
178-
logger,
179-
);
178+
if (uploadResult !== undefined) {
179+
await upload_lib.waitForProcessing(
180+
getRepositoryNwo(),
181+
uploadResult.sarifID,
182+
logger,
183+
);
184+
}
180185
// The code quality service does not currently have an endpoint to wait for SARIF processing,
181186
// so we can't wait for that here.
182187
}
183-
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
188+
await sendSuccessStatusReport(
189+
startedAt,
190+
uploadResult?.statusReport || {},
191+
logger,
192+
);
184193
} catch (unwrappedError) {
185194
const error =
186195
isThirdPartyAnalysis(ActionName.UploadSarif) &&

0 commit comments

Comments
 (0)