Compare commits

..

42 commits
v4.0.0 ... main

Author SHA1 Message Date
Bethany
c850b930e6
Merge pull request #307 from bethanyj28/main
Update @actions/artifact
2024-03-01 13:27:40 -05:00
bethanyj28
6fd111f15a update @actions/artifact 2024-03-01 13:20:31 -05:00
Bethany
87c55149d9
Merge pull request #303 from bethanyj28/main
Update @actions/artifact
2024-02-26 10:45:15 -05:00
bethanyj28
47f9ce604f update @actions/artifact 2024-02-26 10:40:04 -05:00
Bethany
127824d34c
Merge pull request #299 from bethanyj28/main
Update toolkit dependency with updated unzip logic
2024-02-23 16:56:43 -05:00
bethanyj28
6dd49bff0a licensed only artifact 2024-02-23 16:51:43 -05:00
bethanyj28
f71c0e3da3 Revert "licensed"
This reverts commit 7c63dfde29.
2024-02-23 16:51:09 -05:00
bethanyj28
7c63dfde29 licensed 2024-02-23 16:49:11 -05:00
bethanyj28
67d37cd346 Update toolkit 2024-02-23 16:42:29 -05:00
Konrad Pabjan
348754975e
Update release-new-action-version.yml (#292) 2024-02-05 17:20:20 -05:00
eggyhead
eaceaf801f
Merge pull request #291 from actions/eggyhead/update-artifact-v2.1.1
updating artifact dependency to version 2.1.1
2024-02-05 13:20:19 -08:00
eggyhead
81eafdc926 update artifact license 2024-02-05 17:53:17 +00:00
eggyhead
9ac5cad9e2 updating artifact dependency to version 2.1.1 2024-02-05 17:25:55 +00:00
Rob Herley
3ad8411bbd
Merge pull request #287 from actions/robherley/sync-migration-docs
Sync migration docs with upload-artifact
2024-01-31 12:42:51 -05:00
Rob Herley
1de464352c
Sync migration docs with upload-artifact
We've updated them quite a bit in upload-artifact so let's make sure we're consistent.
2024-01-31 12:36:02 -05:00
Rob Herley
bb3fa7fd35
Merge pull request #275 from actions/robherley/better-log-msgs
Clarify log messages when using `pattern` or `merge-multiple` params
2024-01-10 16:00:02 -05:00
Rob Herley
a244de5a62
ncc 2024-01-10 15:17:47 -05:00
Rob Herley
355659bff2
clarify log messages when using pattern/merge-multiple params 2024-01-10 15:15:52 -05:00
Vallie Joseph
6b208ae046
Merge pull request #274 from actions/vmjoseph/timeout-patch
Add patch fix for transient timeout issues from new artifact's package
2024-01-10 12:01:10 -05:00
Vallie Joseph
6c5b5806e1 only adding updated license 2024-01-10 16:49:33 +00:00
Vallie Joseph
5f5015dc38 readding index 2024-01-10 16:48:45 +00:00
Vallie Joseph
1fddaaf0f1 Revert "updating licenses"
This reverts commit 657edd9b81.
2024-01-10 16:48:01 +00:00
Vallie Joseph
8aa9e2115b Revert "updating dist"
This reverts commit 555a2fc129.
2024-01-10 16:47:16 +00:00
Vallie Joseph
657edd9b81 updating licenses 2024-01-10 16:44:54 +00:00
Vallie Joseph
555a2fc129 updating dist 2024-01-10 16:18:33 +00:00
Vallie Joseph
4fc4d70d4c updating lock 2024-01-10 16:12:36 +00:00
Vallie Joseph
072ac9dceb updating version no 2024-01-10 16:00:45 +00:00
Vallie Joseph
038dc0329f updating version no 2024-01-10 15:59:40 +00:00
Vallie Joseph
3f40cd641f updating release 2024-01-10 15:58:28 +00:00
Vallie Joseph
82c243c150 updating artifacts package 2024-01-10 15:31:35 +00:00
Rob Herley
f44cd7b40b
Merge pull request #259 from actions/robherley/glob-downloads
Support pattern matching to filter artifacts & merge to same directory
2023-12-18 17:22:01 -05:00
Rob Herley
3181fe853d
add some migration docs 2023-12-18 16:53:40 -05:00
Rob Herley
aaaac7b403
licensed cache 2023-12-18 16:48:08 -05:00
Rob Herley
7c9182f0e1
update readme 2023-12-18 16:33:36 -05:00
Rob Herley
b94e701556
licensed cache 2023-12-18 15:43:18 -05:00
Rob Herley
0b55470e40
add test case for globbed downloads to same directory 2023-12-18 12:43:05 -05:00
Rob Herley
0b51c2ef90
update prettier/eslint versions 2023-12-15 17:46:13 -05:00
Rob Herley
c4c6db724f
support globbing artifact list & merging download directory 2023-12-15 17:18:41 -05:00
Rob Herley
1bd0606e08
Merge pull request #252 from stchr/patch-1
fix default for run-id
2023-12-15 14:17:02 -05:00
Simon Stücher
eff4d42b1f
fix default for run-id
See https://github.com/actions/download-artifact/blob/main/action.yml#L25
2023-12-15 12:56:01 +01:00
Rob Herley
4e2cbd8192
Merge pull request #247 from actions/robherley/misc-updates
Some cleanup
2023-12-14 15:14:24 -05:00
Rob Herley
bf8f7d968a
remove references to v4-beta 2023-12-14 15:10:05 -05:00
15 changed files with 10094 additions and 4775 deletions

View file

@ -9,8 +9,7 @@
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"]
}

View file

@ -46,7 +46,7 @@ jobs:
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v4-beta
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist

View file

@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.1
uses: actions/publish-action@v0.3.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View file

@ -48,13 +48,13 @@ jobs:
echo "Hello world from file B" > path/to/artifact-B/file-B.txt
- name: Upload artifact A
uses: actions/upload-artifact@v4-beta
uses: actions/upload-artifact@v4
with:
name: Artifact-A-${{ matrix.runs-on }}
path: path/to/artifact-A
- name: Upload artifact B
uses: actions/upload-artifact@v4-beta
uses: actions/upload-artifact@v4
with:
name: Artifact-B-${{ matrix.runs-on }}
path: path/to/artifact-B
@ -106,3 +106,25 @@ jobs:
Write-Error "File contents of downloaded artifacts are incorrect"
}
shell: pwsh
# Test glob downloading both artifacts to same directory
- name: Download all Artifacts
uses: ./
with:
pattern: Artifact-*
path: single/directory
merge-multiple: true
- name: Verify successful download
run: |
$fileA = "single/directory/file-A.txt"
$fileB = "single/directory/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

View file

@ -1,6 +1,6 @@
---
name: "@actions/artifact"
version: 2.0.0
version: 2.1.4
type: npm
summary: Actions artifact lib
homepage: https://github.com/actions/toolkit/tree/main/packages/artifact

26
.licenses/npm/minimatch-9.0.3.dep.yml generated Normal file
View file

@ -0,0 +1,26 @@
---
name: minimatch
version: 9.0.3
type: npm
summary: a glob matcher in javascript
homepage:
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
notices: []

26
.licenses/npm/minimatch.dep.yml generated Normal file
View file

@ -0,0 +1,26 @@
---
name: minimatch
version: 9.0.3
type: npm
summary:
homepage:
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
notices: []

View file

@ -14,6 +14,7 @@ See also [upload-artifact](https://github.com/actions/upload-artifact).
- [Examples](#examples)
- [Download Single Artifact](#download-single-artifact)
- [Download All Artifacts](#download-all-artifacts)
- [Download multiple (filtered) Artifacts to the same directory](#download-multiple-filtered-artifacts-to-the-same-directory)
- [Download Artifacts from other Workflow Runs or Repositories](#download-artifacts-from-other-workflow-runs-or-repositories)
- [Limitations](#limitations)
- [Permission Loss](#permission-loss)
@ -38,6 +39,8 @@ For more information, see the [`@actions/artifact`](https://github.com/actions/t
1. On self hosted runners, additional [firewall rules](https://github.com/actions/toolkit/tree/main/packages/artifact#breaking-changes) may be required.
2. Downloading artifacts that were created from `action/upload-artifact@v3` and below are not supported.
For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
## Usage
### Inputs
@ -46,13 +49,25 @@ For more information, see the [`@actions/artifact`](https://github.com/actions/t
- uses: actions/download-artifact@v4
with:
# Name of the artifact to download.
# Optional. If unspecified, all artifacts for the run are downloaded.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name:
# Destination path. Supports basic tilde expansion.
# Optional. Defaults is $GITHUB_WORKSPACE
# Optional. Default is $GITHUB_WORKSPACE
path:
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Optional. Default is 'false'
merge-multiple:
# The GitHub token used to authenticate with the GitHub API.
# This is required when downloading artifacts from a different repository or from a different workflow run.
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
@ -65,7 +80,7 @@ For more information, see the [`@actions/artifact`](https://github.com/actions/t
# The id of the workflow run where the desired download artifact was uploaded from.
# If github-token is specified, this is the run that artifacts will be downloaded from.
# Optional. Default is ${{ github.repository }}
# Optional. Default is ${{ github.run_id }}
run-id:
```
@ -105,7 +120,7 @@ steps:
### Download All Artifacts
If the `name` input parameter is not provided, all artifacts will be downloaded. **To differentiate between downloaded artifacts, a directory denoted by the artifacts name will be created for each individual artifact.**
If the `name` input parameter is not provided, all artifacts will be downloaded. To differentiate between downloaded artifacts, by default a directory denoted by the artifacts name will be created for each individual artifact. This behavior can be changed with the `merge-multiple` input parameter.
Example, if there are two artifacts `Artifact-A` and `Artifact-B`, and the directory is `etc/usr/artifacts/`, the directory structure will look like this:
@ -137,6 +152,67 @@ steps:
run: ls -R path/to/artifacts
```
To download them to the _same_ directory:
```yaml
steps:
- uses: actions/download-artifact@v4
with:
path: path/to/artifacts
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R path/to/artifacts
```
Which will result in:
```
path/to/artifacts/
... contents of Artifact-A
... contents of Artifact-B
```
### Download multiple (filtered) Artifacts to the same directory
In multiple arch/os scenarios, you may have Artifacts built in different jobs. To download all Artifacts to the same directory (or matching a glob pattern), you can use the `pattern` and `merge-multiple` inputs.
```yaml
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: my-artifact-${{ matrix.runs-on }}
path: file-${{ matrix.runs-on }}.txt
download:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: my-artifact
pattern: my-artifact-*
merge-multiple: true
- run: ls -R my-artifact
```
This results in a directory like so:
```
my-artifact/
file-macos-latest.txt
file-ubuntu-latest.txt
file-windows-latest.txt
```
### Download Artifacts from other Workflow Runs or Repositories
It may be useful to download Artifacts from other workflow runs, or even other repositories. By default, the permissions are scoped so they can only download Artifacts within the current workflow run. To elevate permissions for this scenario, you can specify a `github-token` along with other repository and run identifiers:

View file

@ -3,11 +3,20 @@ description: 'Download a build artifact that was previously uploaded in the work
author: 'GitHub'
inputs:
name:
description: 'Name of the artifact to download. If unspecified, all artifacts for the run are downloaded'
description: 'Name of the artifact to download. If unspecified, all artifacts for the run are downloaded.'
required: false
path:
description: 'Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE'
required: false
pattern:
description: 'A glob pattern matching the artifacts that should be downloaded. Ignored if name is specified.'
required: false
merge-multiple:
description: 'When multiple artifacts are matched, this changes the behavior of the destination directories.
If true, the downloaded artifacts will be in the same directory specified by path.
If false, the downloaded artifacts will be extracted into individual named directories within the specified path.'
required: false
default: 'false'
github-token:
description: 'The GitHub token used to authenticate with the GitHub API.
This is required when downloading artifacts from a different repository or from a different workflow run.

8059
dist/index.js vendored

File diff suppressed because one or more lines are too long

208
docs/MIGRATION.md Normal file
View file

@ -0,0 +1,208 @@
# Migration
- [Migration](#migration)
- [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact)
- [Overwriting an Artifact](#overwriting-an-artifact)
- [Merging multiple artifacts](#merging-multiple-artifacts)
Several behavioral differences exist between Artifact actions `v3` and below vs `v4`. This document outlines common scenarios in `v3`, and how they would be handled in `v4`.
## Multiple uploads to the same named Artifact
In `v3`, Artifacts are _mutable_ so it's possible to write workflow scenarios where multiple jobs upload to the same Artifact like so:
```yaml
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: my-artifact # NOTE: same artifact name
path: file-${{ matrix.runs-on }}.txt
download:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v3
with:
name: my-artifact
path: my-artifact
- run: ls -R my-artifact
```
This results in a directory like so:
```
my-artifact/
file-macos-latest.txt
file-ubuntu-latest.txt
file-windows-latest.txt
```
In v4, Artifacts are immutable (unless deleted). So you must change each of the uploaded Artifacts to have a different name and filter the downloads by name to achieve the same effect:
```diff
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
- name: my-artifact
+ name: my-artifact-${{ matrix.runs-on }}
path: file-${{ matrix.runs-on }}.txt
download:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
- name: my-artifact
path: my-artifact
+ pattern: my-artifact-*
+ merge-multiple: true
- run: ls -R my-artifact
```
In `v4`, the new `pattern:` input will filter the downloaded Artifacts to match the name specified. The new `merge-multiple:` input will support downloading multiple Artifacts to the same directory. If the files within the Artifacts have the same name, the last writer wins.
## Overwriting an Artifact
In `v3`, the contents of an Artifact were mutable so something like the following was possible:
```yaml
jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Create a file
run: echo "hello world" > my-file.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: my-artifact # NOTE: same artifact name
path: my-file.txt
upload-again:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Create a different file
run: echo "goodbye world" > my-file.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: my-artifact # NOTE: same artifact name
path: my-file.txt
```
The resulting `my-file.txt` in `my-artifact` will have "goodbye world" as the content.
In `v4`, Artifacts are immutable unless deleted. To achieve this same behavior, you can use `overwrite: true` to delete the Artifact before a new one is created:
```diff
jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Create a file
run: echo "hello world" > my-file.txt
- name: Upload Artifact
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: my-artifact # NOTE: same artifact name
path: my-file.txt
upload-again:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Create a different file
run: echo "goodbye world" > my-file.txt
- name: Upload Artifact
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: my-artifact # NOTE: same artifact name
path: my-file.txt
+ overwrite: true
```
Note that this will create an _entirely_ new Artifact, with a different ID from the previous.
## Merging multiple artifacts
In `v3`, multiple uploads from multiple jobs could be done to the same Artifact. This would result in a single archive, which could be useful for sending to upstream systems outside of Actions via API or UI downloads.
```yaml
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: all-my-files # NOTE: same artifact name
path: file-${{ matrix.runs-on }}.txt
```
The single `all-my-files` artifact would contain the following:
```
.
∟ file-ubuntu-latest.txt
∟ file-macos-latest.txt
∟ file-windows-latest.txt
```
To achieve the same in `v4` you can change it like so:
```diff
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
- name: all-my-files
+ name: my-artifact-${{ matrix.runs-on }}
path: file-${{ matrix.runs-on }}.txt
+ merge:
+ runs-on: ubuntu-latest
+ needs: upload
+ steps:
+ - name: Merge Artifacts
+ uses: actions/upload-artifact/merge@v4
+ with:
+ name: all-my-files
+ pattern: my-artifact-*
```
Note that this will download all artifacts to a temporary directory and reupload them as a single artifact. For more information on inputs and other use cases for `actions/upload-artifact/merge@v4`, see [the action documentation](../merge/README.md).

6201
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "download-artifact",
"version": "4.0.0",
"version": "4.1.4",
"description": "Download an Actions Artifact from a workflow run",
"main": "dist/index.js",
"scripts": {
@ -28,18 +28,20 @@
},
"homepage": "https://github.com/actions/download-artifact#readme",
"dependencies": {
"@actions/artifact": "^2.0.0",
"@actions/artifact": "^2.1.1",
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1"
"@actions/github": "^5.1.1",
"minimatch": "^9.0.3"
},
"devDependencies": {
"@types/node": "^12.12.6",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@vercel/ncc": "^0.33.4",
"concurrently": "^5.2.0",
"eslint": "^7.4.0",
"eslint-plugin-github": "^4.1.1",
"prettier": "^2.0.5",
"typescript": "^3.8.3"
"eslint": "^8.55.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.1",
"typescript": "^5.3.3"
}
}

View file

@ -3,7 +3,9 @@ export enum Inputs {
Path = 'path',
GitHubToken = 'github-token',
Repository = 'repository',
RunID = 'run-id'
RunID = 'run-id',
Pattern = 'pattern',
MergeMultiple = 'merge-multiple'
}
export enum Outputs {

View file

@ -3,6 +3,7 @@ import * as path from 'path'
import * as core from '@actions/core'
import artifactClient from '@actions/artifact'
import type {Artifact, FindOptions} from '@actions/artifact'
import {Minimatch} from 'minimatch'
import {Inputs, Outputs} from './constants'
const PARALLEL_DOWNLOADS = 5
@ -20,7 +21,9 @@ async function run(): Promise<void> {
path: core.getInput(Inputs.Path, {required: false}),
token: core.getInput(Inputs.GitHubToken, {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})),
pattern: core.getInput(Inputs.Pattern, {required: false}),
mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {required: false})
}
if (!inputs.path) {
@ -72,29 +75,47 @@ async function run(): Promise<void> {
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({
latest: true,
...options
})
artifacts = listArtifactResponse.artifacts
if (listArtifactResponse.artifacts.length === 0) {
throw new Error(
`No artifacts found for run '${inputs.runID}' in '${inputs.repository}'`
core.debug(`Found ${artifacts.length} artifacts in run`)
if (inputs.pattern) {
core.info(`Filtering artifacts by pattern '${inputs.pattern}'`)
const matcher = new Minimatch(inputs.pattern)
artifacts = artifacts.filter(artifact => matcher.match(artifact.name))
core.debug(
`Filtered from ${listArtifactResponse.artifacts.length} to ${artifacts.length} artifacts`
)
} else {
core.info(
'No input name or pattern filtered specified, downloading all artifacts'
)
if (!inputs.mergeMultiple) {
core.info(
'An extra directory with the artifact name will be created for each download'
)
}
}
}
core.debug(`Found ${listArtifactResponse.artifacts.length} artifacts`)
artifacts = listArtifactResponse.artifacts
if (artifacts.length) {
core.info(`Preparing to download the following artifacts:`)
artifacts.forEach(artifact => {
core.info(
`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`
)
})
}
const downloadPromises = artifacts.map(artifact =>
artifactClient.downloadArtifact(artifact.id, {
...options,
path: isSingleArtifactDownload
path:
isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name)
})