diff --git a/action.yml b/action.yml index 898a840..0fd14b9 100644 --- a/action.yml +++ b/action.yml @@ -25,5 +25,5 @@ outputs: download-path: description: 'Path of artifact download' runs: - using: 'node16' + using: 'node20' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 76b0501..312a325 100644 --- a/dist/index.js +++ b/dist/index.js @@ -118706,6 +118706,7 @@ function run() { if (inputs.path.startsWith(`~`)) { inputs.path = inputs.path.replace('~', os.homedir()); } + const isSingleArtifactDownload = !!inputs.name; const resolvedPath = path.resolve(inputs.path); core.debug(`Resolved path is ${resolvedPath}`); const [owner, repo] = inputs.repository.split('/'); @@ -118714,7 +118715,8 @@ function run() { } const artifactClient = artifact.create(); let artifacts = []; - if (inputs.name) { + if (isSingleArtifactDownload) { + core.info(`Downloading single artifact`); const { artifact: targetArtifact } = yield artifactClient.getArtifact(inputs.name, inputs.runID, owner, repo, inputs.token); if (!targetArtifact) { throw new Error(`Artifact '${inputs.name}' not found`); @@ -118723,6 +118725,7 @@ function run() { artifacts = [targetArtifact]; } else { + core.info(`No input name specified, downloading all artifacts. Extra directory with the artifact name will be created for each download`); const listArtifactResponse = yield artifactClient.listArtifacts(inputs.runID, owner, repo, inputs.token); if (listArtifactResponse.artifacts.length === 0) { throw new Error(`No artifacts found for run '${inputs.runID}' in '${inputs.repository}'`); @@ -118731,7 +118734,7 @@ function run() { artifacts = listArtifactResponse.artifacts; } const downloadPromises = artifacts.map(artifact => artifactClient.downloadArtifact(artifact.id, owner, repo, inputs.token, { - path: path.join(resolvedPath, artifact.name) + path: isSingleArtifactDownload ? resolvedPath : path.join(resolvedPath, artifact.name) })); const chunkedPromises = exports.chunk(downloadPromises, PARALLEL_DOWNLOADS); for (const chunk of chunkedPromises) { diff --git a/src/download-artifact.ts b/src/download-artifact.ts index 2cdb916..778f899 100644 --- a/src/download-artifact.ts +++ b/src/download-artifact.ts @@ -30,6 +30,7 @@ async function run(): Promise { inputs.path = inputs.path.replace('~', os.homedir()) } + const isSingleArtifactDownload: boolean = !!inputs.name const resolvedPath = path.resolve(inputs.path) core.debug(`Resolved path is ${resolvedPath}`) @@ -43,7 +44,9 @@ async function run(): Promise { const artifactClient = artifact.create() let artifacts: artifact.Artifact[] = [] - if (inputs.name) { + if (isSingleArtifactDownload) { + core.info(`Downloading single artifact`) + const {artifact: targetArtifact} = await artifactClient.getArtifact( inputs.name, inputs.runID, @@ -62,6 +65,8 @@ async function run(): Promise { artifacts = [targetArtifact] } else { + core.info(`No input name specified, downloading all artifacts. Extra directory with the artifact name will be created for each download`) + const listArtifactResponse = await artifactClient.listArtifacts( inputs.runID, owner, @@ -81,7 +86,7 @@ async function run(): Promise { const downloadPromises = artifacts.map(artifact => artifactClient.downloadArtifact(artifact.id, owner, repo, inputs.token, { - path: path.join(resolvedPath, artifact.name) + path: isSingleArtifactDownload ? resolvedPath : path.join(resolvedPath, artifact.name) }) )