diff --git a/dist/index.js b/dist/index.js index f5b5fc1..b702b45 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31165,11 +31165,6 @@ 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 = { @@ -31190,6 +31185,11 @@ function run() { } const getObjectParams = { Bucket: s3Bucket, Key: fileObject.Key }; const localKey = path_1.default.join(resolvedPath, fileObject.Key.replace(s3Prefix, '')); + const localKeyDir = path_1.default.dirname(localKey); + if (!fs.existsSync(localKeyDir)) { + core.debug(`Creating directory (${localKeyDir}) since it did not exist`); + fs.mkdirSync(localKeyDir, { recursive: true }); + } const writeStream = fs.createWriteStream(localKey); core.info(`Started download: ${localKey}`); core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`); diff --git a/src/download-artifact.ts b/src/download-artifact.ts index 1ccd5a5..5437dfa 100644 --- a/src/download-artifact.ts +++ b/src/download-artifact.ts @@ -22,11 +22,6 @@ 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 = { @@ -50,6 +45,13 @@ async function run(): Promise { resolvedPath, fileObject.Key.replace(s3Prefix, '') ) + const localKeyDir = path.dirname(localKey) + if (!fs.existsSync(localKeyDir)) { + core.debug( + `Creating directory (${localKeyDir}) since it did not exist` + ) + fs.mkdirSync(localKeyDir, {recursive: true}) + } const writeStream = fs.createWriteStream(localKey) core.info(`Started download: ${localKey}`) core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`)