mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-23 23:18:29 +02:00
Merge 569e039f2a
into 076f0f7dd0
This commit is contained in:
commit
6973adbac6
15 changed files with 2452 additions and 133 deletions
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
|
@ -4,7 +4,7 @@
|
|||
# For our project, we generate this file through a build process
|
||||
# from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
name: Check dist
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
3
.github/workflows/licensed.yml
vendored
3
.github/workflows/licensed.yml
vendored
|
@ -14,6 +14,9 @@ jobs:
|
|||
name: Check licenses
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
- run: npm ci
|
||||
- name: Install licensed
|
||||
run: |
|
||||
|
|
57
.github/workflows/test.yml
vendored
57
.github/workflows/test.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
|||
run: npm run lint
|
||||
|
||||
- name: Format
|
||||
run: npm run format-check
|
||||
run: npm run format-check
|
||||
|
||||
# Test end-to-end by uploading two artifacts and then downloading them
|
||||
# Once upload-artifact v2 is out of preview, switch over
|
||||
|
@ -48,7 +48,7 @@ jobs:
|
|||
mkdir -p path/to/artifact-B
|
||||
echo "Lorem ipsum dolor sit amet" > path/to/artifact-A/file-A.txt
|
||||
echo "Hello world from file B" > path/to/artifact-B/file-B.txt
|
||||
|
||||
|
||||
- name: Upload artifact A
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
|
@ -89,7 +89,56 @@ jobs:
|
|||
}
|
||||
shell: pwsh
|
||||
|
||||
# Test downloading both artifacts at once
|
||||
# Test downloading multiple artifacts to the same path
|
||||
- name: Download artifacts A and B to the same path
|
||||
uses: ./
|
||||
with:
|
||||
name: |
|
||||
Artifact-A
|
||||
Artifact-B
|
||||
path: some/path/for/multiple/files
|
||||
|
||||
- name: Verify successful download
|
||||
run: |
|
||||
$fileA = "some/path/for/multiple/files/file-A.txt"
|
||||
$fileB = "some/path/for/multiple/files/file-B.txt"
|
||||
if(!(Test-Path -path $fileA) -or !(Test-Path -path $fileB))
|
||||
{
|
||||
Write-Error "Expected files do not exist"
|
||||
}
|
||||
if(!((Get-Content $fileA) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $fileB) -ceq "Hello world from file B"))
|
||||
{
|
||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
# Test downloading multiple artifacts to different paths
|
||||
- name: Download artifacts A and B to different paths
|
||||
uses: ./
|
||||
with:
|
||||
name: |
|
||||
Artifact-A
|
||||
Artifact-B
|
||||
path: |
|
||||
some/path/for/a
|
||||
some/path/for/b
|
||||
|
||||
|
||||
- name: Verify successful download
|
||||
run: |
|
||||
$fileA = "some/path/for/a/file-A.txt"
|
||||
$fileB = "some/path/for/b/file-B.txt"
|
||||
if(!(Test-Path -path $fileA) -or !(Test-Path -path $fileB))
|
||||
{
|
||||
Write-Error "Expected files do not exist"
|
||||
}
|
||||
if(!((Get-Content $fileA) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $fileB) -ceq "Hello world from file B"))
|
||||
{
|
||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
# Test downloading all artifacts
|
||||
- name: Download all Artifacts
|
||||
uses: ./
|
||||
with:
|
||||
|
@ -108,5 +157,3 @@ jobs:
|
|||
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
|
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: "@actions/core"
|
||||
version: 1.2.6
|
||||
version: 1.10.0
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/master/packages/core
|
||||
|
|
32
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
name: "@actions/http-client"
|
||||
version: 1.0.11
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/http-client#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
32
.licenses/npm/@actions/http-client-2.0.1.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client-2.0.1.dep.yml
generated
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
name: "@actions/http-client"
|
||||
version: 2.0.1
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
2
.licenses/npm/rimraf.dep.yml
generated
2
.licenses/npm/rimraf.dep.yml
generated
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: rimraf
|
||||
version: 2.6.3
|
||||
version: 3.0.2
|
||||
type: npm
|
||||
summary: A deep deletion module for node (like `rm -rf`)
|
||||
homepage: https://github.com/isaacs/rimraf#readme
|
||||
|
|
2
.licenses/npm/tmp-promise.dep.yml
generated
2
.licenses/npm/tmp-promise.dep.yml
generated
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: tmp-promise
|
||||
version: 2.1.1
|
||||
version: 3.0.3
|
||||
type: npm
|
||||
summary: The tmp package with promises support and disposers.
|
||||
homepage: https://github.com/benjamingr/tmp-promise#readme
|
||||
|
|
2
.licenses/npm/tmp.dep.yml
generated
2
.licenses/npm/tmp.dep.yml
generated
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: tmp
|
||||
version: 0.1.0
|
||||
version: 0.2.1
|
||||
type: npm
|
||||
summary: Temporary file and directory creator
|
||||
homepage: http://github.com/raszi/node-tmp
|
||||
|
|
39
.licenses/npm/uuid.dep.yml
generated
Normal file
39
.licenses/npm/uuid.dep.yml
generated
Normal file
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
name: uuid
|
||||
version: 8.3.2
|
||||
type: npm
|
||||
summary: RFC4122 (v1, v4, and v5) UUIDs
|
||||
homepage: https://github.com/kelektiv/node-uuid#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices:
|
||||
- sources: AUTHORS
|
||||
text: |-
|
||||
Robert Kieffer <robert@broofa.com>
|
||||
Christoph Tavan <dev@tavan.de>
|
||||
AJ ONeal <coolaj86@gmail.com>
|
||||
Vincent Voyer <vincent@zeroload.net>
|
||||
Roman Shtylman <shtylman@gmail.com>
|
2204
dist/index.js
vendored
2204
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
53
package-lock.json
generated
53
package-lock.json
generated
|
@ -10,7 +10,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^1.0.0",
|
||||
"@actions/core": "^1.2.6"
|
||||
"@actions/core": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.6",
|
||||
|
@ -35,9 +35,21 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
|
@ -2955,6 +2967,14 @@
|
|||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-compile-cache": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
||||
|
@ -3144,9 +3164,23 @@
|
|||
}
|
||||
},
|
||||
"@actions/core": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"requires": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
|
@ -5326,6 +5360,11 @@
|
|||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
},
|
||||
"v8-compile-cache": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"homepage": "https://github.com/actions/download-artifact#readme",
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^1.0.0",
|
||||
"@actions/core": "^1.2.6"
|
||||
"@actions/core": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.6",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export enum Inputs {
|
||||
Name = 'name',
|
||||
Path = 'path'
|
||||
Names = 'name',
|
||||
Paths = 'path'
|
||||
}
|
||||
export enum Outputs {
|
||||
DownloadPath = 'download-path'
|
||||
DownloadPaths = 'download-path'
|
||||
}
|
||||
|
|
|
@ -4,55 +4,118 @@ import * as os from 'os'
|
|||
import {resolve} from 'path'
|
||||
import {Inputs, Outputs} from './constants'
|
||||
|
||||
async function downloadArtifact(name: string, path: string): Promise<string> {
|
||||
let resolvedPath
|
||||
// resolve tilde expansions, path.replace only replaces the first occurrence of a pattern
|
||||
if (path.startsWith(`~`)) {
|
||||
resolvedPath = resolve(path.replace('~', os.homedir()))
|
||||
} else {
|
||||
resolvedPath = resolve(path)
|
||||
}
|
||||
core.debug(`Resolved path is ${resolvedPath}`)
|
||||
|
||||
const artifactClient = artifact.create()
|
||||
if (!name) {
|
||||
// download all artifacts
|
||||
core.info('No artifact name specified, downloading all artifacts')
|
||||
core.info(
|
||||
'Creating an extra directory for each artifact that is being downloaded'
|
||||
)
|
||||
const downloadResponse = await artifactClient.downloadAllArtifacts(
|
||||
resolvedPath
|
||||
)
|
||||
core.info(`There were ${downloadResponse.length} artifacts downloaded`)
|
||||
for (const artifact of downloadResponse) {
|
||||
core.info(
|
||||
`Artifact ${artifact.artifactName} was downloaded to ${artifact.downloadPath}`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// download a single artifact
|
||||
core.info(`Starting download for ${name}`)
|
||||
const downloadOptions = {
|
||||
createArtifactFolder: false
|
||||
}
|
||||
const downloadResponse = await artifactClient.downloadArtifact(
|
||||
name,
|
||||
resolvedPath,
|
||||
downloadOptions
|
||||
)
|
||||
core.info(
|
||||
`Artifact ${downloadResponse.artifactName} was downloaded to ${downloadResponse.downloadPath}`
|
||||
)
|
||||
}
|
||||
// output the directory that the artifact(s) was/were downloaded to
|
||||
// if no path is provided, an empty string resolves to the current working directory
|
||||
core.info('Artifact download has finished successfully')
|
||||
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const name = core.getInput(Inputs.Name, {required: false})
|
||||
const path = core.getInput(Inputs.Path, {required: false})
|
||||
const names = core.getMultilineInput(Inputs.Names, {required: false})
|
||||
const paths = core.getMultilineInput(Inputs.Paths, {required: false})
|
||||
|
||||
let resolvedPath
|
||||
// resolve tilde expansions, path.replace only replaces the first occurrence of a pattern
|
||||
if (path.startsWith(`~`)) {
|
||||
resolvedPath = resolve(path.replace('~', os.homedir()))
|
||||
} else {
|
||||
resolvedPath = resolve(path)
|
||||
}
|
||||
core.debug(`Resolved path is ${resolvedPath}`)
|
||||
core.info(`names: '${JSON.stringify(names)}' | length: ${names.length}`)
|
||||
core.info(`paths: '${JSON.stringify(paths)}' | length: ${paths.length}`)
|
||||
|
||||
const artifactClient = artifact.create()
|
||||
if (!name) {
|
||||
// download all artifacts
|
||||
core.info('No artifact name specified, downloading all artifacts')
|
||||
core.info(
|
||||
'Creating an extra directory for each artifact that is being downloaded'
|
||||
)
|
||||
const downloadResponse = await artifactClient.downloadAllArtifacts(
|
||||
resolvedPath
|
||||
)
|
||||
core.info(`There were ${downloadResponse.length} artifacts downloaded`)
|
||||
for (const artifact of downloadResponse) {
|
||||
core.info(
|
||||
`Artifact ${artifact.artifactName} was downloaded to ${artifact.downloadPath}`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// download a single artifact
|
||||
core.info(`Starting download for ${name}`)
|
||||
const downloadOptions = {
|
||||
createArtifactFolder: false
|
||||
}
|
||||
const downloadResponse = await artifactClient.downloadArtifact(
|
||||
name,
|
||||
resolvedPath,
|
||||
downloadOptions
|
||||
)
|
||||
core.info(
|
||||
`Artifact ${downloadResponse.artifactName} was downloaded to ${downloadResponse.downloadPath}`
|
||||
let downloadPaths: string[] = []
|
||||
|
||||
// Names is set and has fewer entries than Paths
|
||||
if (names.length !== 0 && paths.length > names.length) {
|
||||
throw Error(
|
||||
`The input 'path' cannot have more entries than 'name', if 'name' is set.`
|
||||
)
|
||||
}
|
||||
// Names is NOT set and Paths has more than 1 entry
|
||||
else if (names.length === 0 && paths.length > 1) {
|
||||
throw Error(
|
||||
`The input 'path' cannot have more than one entry, if 'name' is not set.`
|
||||
)
|
||||
}
|
||||
// Names is NOT set and path has at max 1 entry: download all artifacts
|
||||
else if (names.length === 0 && paths.length <= 1) {
|
||||
const name = names.toString() // ''
|
||||
const path = paths.toString() // '' or 'some/path'
|
||||
const downloadPath = await downloadArtifact(name, path)
|
||||
downloadPaths.push(downloadPath)
|
||||
}
|
||||
// Names has one or more entries and Paths has at max 1 entry
|
||||
else if (names.length >= 1 && paths.length <= 1) {
|
||||
const path = paths.toString() // '' or 'some/path'
|
||||
names.forEach(async name => {
|
||||
const downloadPath = await downloadArtifact(name, path)
|
||||
downloadPaths.push(downloadPath)
|
||||
})
|
||||
}
|
||||
// Names and Paths have the same numbers of entries (more than 1)
|
||||
else if (
|
||||
names.length > 1 &&
|
||||
paths.length > 1 &&
|
||||
names.length === paths.length
|
||||
) {
|
||||
names.forEach(async (name, index) => {
|
||||
const path = paths[index]
|
||||
const downloadPath = await downloadArtifact(name, path)
|
||||
downloadPaths.push(downloadPath)
|
||||
})
|
||||
}
|
||||
// Unhandled exception
|
||||
else {
|
||||
throw Error(
|
||||
`Unhandled scenario. This shouldn't happen. It's very likely a bug. :-()`
|
||||
)
|
||||
}
|
||||
|
||||
// Remove duplicates and empty strings
|
||||
downloadPaths = [...new Set(downloadPaths.filter(path => path !== ''))]
|
||||
|
||||
// Returns a newline-separated list of paths
|
||||
const output = downloadPaths.join('\n')
|
||||
|
||||
// output the directory that the artifact(s) was/were downloaded to
|
||||
// if no path is provided, an empty string resolves to the current working directory
|
||||
core.setOutput(Outputs.DownloadPath, resolvedPath)
|
||||
core.info('Artifact download has finished successfully')
|
||||
core.setOutput(Outputs.DownloadPaths, output)
|
||||
} catch (err) {
|
||||
core.setFailed(err.message)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue