From 5b4e84811e08c8c327c3a605154b1219ce2e8df3 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Wed, 19 May 2021 11:57:07 -0700 Subject: [PATCH] ensure directory is created before downloading Signed-off-by: Eli Uriegas --- dist/index.js | 5 +++++ src/download-artifact.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/dist/index.js b/dist/index.js index f38ea5e..9af2575 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31165,6 +31165,11 @@ function run() { resolvedPath = path_1.default.resolve(chosenPath); } core.debug(`Resolved path is ${resolvedPath}`); + // Create directory if it doesn't already exist + if (!fs.existsSync(resolvedPath)) { + core.debug(`Creating directory (${resolvedPath}) since it did not exist`); + fs.mkdirSync(resolvedPath, { recursive: true }); + } const s3 = new AWS.S3({ region: region }); const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}/`; const s3Params = { diff --git a/src/download-artifact.ts b/src/download-artifact.ts index 84617a7..3dda87b 100644 --- a/src/download-artifact.ts +++ b/src/download-artifact.ts @@ -22,6 +22,11 @@ async function run(): Promise { resolvedPath = path.resolve(chosenPath) } core.debug(`Resolved path is ${resolvedPath}`) + // Create directory if it doesn't already exist + if (!fs.existsSync(resolvedPath)) { + core.debug(`Creating directory (${resolvedPath}) since it did not exist`) + fs.mkdirSync(resolvedPath, {recursive: true}) + } const s3 = new AWS.S3({region: region}) const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}/` const s3Params = {