diff --git a/lib/manageArtifacts.js b/lib/manageArtifacts.js index 32f7cb23..4c8bf17a 100644 --- a/lib/manageArtifacts.js +++ b/lib/manageArtifacts.js @@ -88,16 +88,17 @@ const storeArtifact = (variables) => __awaiter(void 0, void 0, void 0, function* }); const retrieveArtifact = (variables) => __awaiter(void 0, void 0, void 0, function* () { const client = artifact.create(); + rimraf_1.default.sync(config_1.WORKDIR); + fs_1.mkdirSync(config_1.WORKDIR); for (const variable of variables) { try { - rimraf_1.default.sync(config_1.WORKDIR); - fs_1.mkdirSync(config_1.WORKDIR); const file = path_1.join(config_1.WORKDIR, `${variable.key}.txt`); yield client.downloadAllArtifacts(variable.key); variable.value = fs_1.readFileSync(file, { encoding: 'utf8' }).toString(); } catch (error) { core.warning(`Cannot retrieve variable ${variable.key}`); + console.error(error); } } }); diff --git a/src/manageArtifacts.ts b/src/manageArtifacts.ts index 5b0eacb2..bbb5cbc4 100644 --- a/src/manageArtifacts.ts +++ b/src/manageArtifacts.ts @@ -9,8 +9,9 @@ import {readFileSync, mkdirSync, writeFileSync} from 'fs'; import * as core from '@actions/core'; import {VariableDetail, VariableStatus} from "./types/variableStatus"; import {WORKDIR} from "./config"; -import {ArtifactClient, UploadOptions} from "@actions/artifact"; import rimraf from "rimraf"; +import {ArtifactClient, UploadOptions} from "@actions/artifact"; +import {UploadResponse} from "@actions/artifact/lib/internal/upload-response"; const artifact = require('@actions/artifact'); const io = require('@actions/io'); @@ -44,7 +45,7 @@ const storeArtifact = async (variables: VariableDetail[]): Promise => { const artifactOptions: UploadOptions = { retentionDays: 1 // Only keep artifacts 1 day to avoid reach limit: https://github.com/actions/toolkit/blob/c861dd8859fe5294289fcada363ce9bc71e9d260/packages/artifact/src/internal/upload-options.ts#L1 } - const artifactsUploadPromises: Promise[] = []; + const artifactsUploadPromises: Promise[] = []; rimraf.sync(WORKDIR); mkdirSync(WORKDIR); @@ -62,15 +63,16 @@ const storeArtifact = async (variables: VariableDetail[]): Promise => { const retrieveArtifact = async (variables: VariableDetail[]): Promise => { const client: ArtifactClient = artifact.create(); + rimraf.sync(WORKDIR); + mkdirSync(WORKDIR); for (const variable of variables) { try { - rimraf.sync(WORKDIR); - mkdirSync(WORKDIR); const file = join(WORKDIR, `${variable.key}.txt`); await client.downloadAllArtifacts(variable.key); variable.value = readFileSync(file, {encoding: 'utf8'}).toString(); } catch (error) { core.warning(`Cannot retrieve variable ${variable.key}`) + console.error(error); } } }