mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-25 07:58:33 +02:00
Add option to not create separate directories for multi-artifacts
Fixes #213
This commit is contained in:
parent
1bd0606e08
commit
2d9dd3aa41
2 changed files with 15 additions and 6 deletions
|
@ -3,7 +3,8 @@ export enum Inputs {
|
||||||
Path = 'path',
|
Path = 'path',
|
||||||
GitHubToken = 'github-token',
|
GitHubToken = 'github-token',
|
||||||
Repository = 'repository',
|
Repository = 'repository',
|
||||||
RunID = 'run-id'
|
RunID = 'run-id',
|
||||||
|
NoSeparateDirectory = 'no-separate-directory'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
|
|
@ -20,7 +20,8 @@ async function run(): Promise<void> {
|
||||||
path: core.getInput(Inputs.Path, {required: false}),
|
path: core.getInput(Inputs.Path, {required: false}),
|
||||||
token: core.getInput(Inputs.GitHubToken, {required: false}),
|
token: core.getInput(Inputs.GitHubToken, {required: false}),
|
||||||
repository: core.getInput(Inputs.Repository, {required: false}),
|
repository: core.getInput(Inputs.Repository, {required: false}),
|
||||||
runID: parseInt(core.getInput(Inputs.RunID, {required: false}))
|
runID: parseInt(core.getInput(Inputs.RunID, {required: false})),
|
||||||
|
noSeparateDirectories: core.getInput(Inputs.NoSeparateDirectory, {required: false})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputs.path) {
|
if (!inputs.path) {
|
||||||
|
@ -31,6 +32,7 @@ async function run(): Promise<void> {
|
||||||
inputs.path = inputs.path.replace('~', os.homedir())
|
inputs.path = inputs.path.replace('~', os.homedir())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const noSeparateDirectories = inputs.noSeparateDirectories === "true";
|
||||||
const isSingleArtifactDownload = !!inputs.name
|
const isSingleArtifactDownload = !!inputs.name
|
||||||
const resolvedPath = path.resolve(inputs.path)
|
const resolvedPath = path.resolve(inputs.path)
|
||||||
core.debug(`Resolved path is ${resolvedPath}`)
|
core.debug(`Resolved path is ${resolvedPath}`)
|
||||||
|
@ -72,9 +74,15 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
artifacts = [targetArtifact]
|
artifacts = [targetArtifact]
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
if (noSeparateDirectories) {
|
||||||
`No input name specified, downloading all artifacts. Extra directory with the artifact name will be created for each download`
|
core.info(
|
||||||
)
|
`No input name specified, downloading all artifacts. All downloads will be saved to the same directory`
|
||||||
|
)
|
||||||
|
} 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({
|
const listArtifactResponse = await artifactClient.listArtifacts({
|
||||||
latest: true,
|
latest: true,
|
||||||
|
@ -94,7 +102,7 @@ async function run(): Promise<void> {
|
||||||
const downloadPromises = artifacts.map(artifact =>
|
const downloadPromises = artifacts.map(artifact =>
|
||||||
artifactClient.downloadArtifact(artifact.id, {
|
artifactClient.downloadArtifact(artifact.id, {
|
||||||
...options,
|
...options,
|
||||||
path: isSingleArtifactDownload
|
path: isSingleArtifactDownload || noSeparateDirectories
|
||||||
? resolvedPath
|
? resolvedPath
|
||||||
: path.join(resolvedPath, artifact.name)
|
: path.join(resolvedPath, artifact.name)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue