Skip to content

Commit

Permalink
fix: format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
swarit-pandey committed Aug 28, 2024
1 parent cfbb586 commit aef4e63
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/post/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "node:fs";
import * as path from "node:path";
import * as core from "@actions/core";
import * as artifact from "@actions/artifact";
import * as core from "@actions/core";
import {
ENCODING,
IS_GITHUB_ACTIONS,
Expand Down Expand Up @@ -130,7 +130,7 @@ async function run(): Promise<void> {
stopKnoxctlScan();
await new Promise((resolve) => setTimeout(resolve, 6000));
processResults();

const outputDir = getOutputDir();
await uploadArtifacts(outputDir);

Expand All @@ -148,25 +148,37 @@ async function run(): Promise<void> {
}

async function uploadArtifacts(outputDir: string): Promise<void> {
if (!IS_GITHUB_ACTIONS) {
log("Running in local environment. Artifact upload is skipped.", "warning");
return;
}
if (!IS_GITHUB_ACTIONS) {
log("Running in local environment. Artifact upload is skipped.", "warning");
return;
}

const artifactClient = artifact.create();
const artifactName = "knoxctl-scan-results";
const files = fs.readdirSync(outputDir).map(file => path.join(outputDir, file));
const artifactClient = artifact.create();
const artifactName = "knoxctl-scan-results";
const files = fs
.readdirSync(outputDir)
.map((file) => path.join(outputDir, file));

log(`Uploading ${files.length} files as artifacts`)
log(`Uploading ${files.length} files as artifacts`);

try {
const uploadResult = await artifactClient.uploadArtifact(artifactName, files, outputDir, {
continueOnError: false
});
try {
const uploadResult = await artifactClient.uploadArtifact(
artifactName,
files,
outputDir,
{
continueOnError: false,
},
);

log(`Artifact upload result: ${uploadResult.artifactName} (${uploadResult.size} bytes)`);
log(
`Artifact upload result: ${uploadResult.artifactName} (${uploadResult.size} bytes)`,
);
} catch (error) {
log(`Failed to upload artifacts: ${error instanceof Error ? error.message : String(error)}`, "error");
log(
`Failed to upload artifacts: ${error instanceof Error ? error.message : String(error)}`,
"error",
);
}
}

Expand Down

0 comments on commit aef4e63

Please sign in to comment.