mirror of
https://github.com/actions/download-artifact.git
synced 2025-12-17 06:59:49 +00:00
Merge 0f36edbf53b117b5b6bbc69deb91d93360311117 into f093f21ca4cfa7c75ccbbc2be54da76a0c7e1f05
This commit is contained in:
commit
3635ad4998
66
.github/workflows/test.yml
vendored
66
.github/workflows/test.yml
vendored
@ -50,13 +50,15 @@ jobs:
|
|||||||
echo "Lorem ipsum dolor sit amet" > path/to/artifact-A/file-A.txt
|
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
|
echo "Hello world from file B" > path/to/artifact-B/file-B.txt
|
||||||
|
|
||||||
- name: Upload artifact A
|
- id: artifact-a
|
||||||
|
name: Upload artifact A
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Artifact-A-${{ matrix.runs-on }}
|
name: Artifact-A-${{ matrix.runs-on }}
|
||||||
path: path/to/artifact-A
|
path: path/to/artifact-A
|
||||||
|
|
||||||
- name: Upload artifact B
|
- id: artifact-b
|
||||||
|
name: Upload artifact B
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Artifact-B-${{ matrix.runs-on }}
|
name: Artifact-B-${{ matrix.runs-on }}
|
||||||
@ -131,3 +133,63 @@ jobs:
|
|||||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||||
}
|
}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
|
# Test glob downloading both artifacts to same directory in zip format
|
||||||
|
- name: Download all Zipped Artifacts
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
pattern: Artifact-*
|
||||||
|
unzip: false
|
||||||
|
path: single/directory
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Verify successful download
|
||||||
|
run: |
|
||||||
|
$fileA = "$(ls single/directory/Artifact-A-*.zip)"
|
||||||
|
$fileB = "$(ls single/directory/Artifact-B-*.zip)"
|
||||||
|
if(!(Test-Path -path $fileA) -or !(Test-Path -path $fileB))
|
||||||
|
{
|
||||||
|
Write-Error "Expected files do not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
unzip $fileA -d single/directory/
|
||||||
|
unzip $fileB -d single/directory/
|
||||||
|
|
||||||
|
$fileA = "single/directory/file-A.txt"
|
||||||
|
$fileB = "single/directory/file-B.txt"
|
||||||
|
|
||||||
|
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 glob downloading both artifacts using it's ids to same directory in zip format
|
||||||
|
- name: Download all Zipped Artifacts
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
artifact-ids: ${{ steps.artifact-a.outputs.artifact-id }},${{ steps.artifact-b.outputs.artifact-id }}
|
||||||
|
unzip: false
|
||||||
|
path: single/directory
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Verify successful download
|
||||||
|
run: |
|
||||||
|
$fileA = "$(ls single/directory/Artifact-A-*.zip)"
|
||||||
|
$fileB = "$(ls single/directory/Artifact-B-*.zip)"
|
||||||
|
if(!(Test-Path -path $fileA) -or !(Test-Path -path $fileB))
|
||||||
|
{
|
||||||
|
Write-Error "Expected files do not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
unzip $fileA -d single/directory/
|
||||||
|
unzip $fileB -d single/directory/
|
||||||
|
|
||||||
|
$fileA = "single/directory/file-A.txt"
|
||||||
|
$fileB = "single/directory/file-B.txt"
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
@ -8,6 +8,10 @@ inputs:
|
|||||||
artifact-ids:
|
artifact-ids:
|
||||||
description: 'IDs of the artifacts to download, comma-separated. Either inputs `artifact-ids` or `name` can be used, but not both.'
|
description: 'IDs of the artifacts to download, comma-separated. Either inputs `artifact-ids` or `name` can be used, but not both.'
|
||||||
required: false
|
required: false
|
||||||
|
unzip:
|
||||||
|
description: 'Whenever to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'
|
||||||
|
required: false
|
||||||
|
default: '*'
|
||||||
path:
|
path:
|
||||||
description: 'Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE'
|
description: 'Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
55919
dist/index.js
vendored
55919
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -6,7 +6,8 @@ export enum Inputs {
|
|||||||
RunID = 'run-id',
|
RunID = 'run-id',
|
||||||
Pattern = 'pattern',
|
Pattern = 'pattern',
|
||||||
MergeMultiple = 'merge-multiple',
|
MergeMultiple = 'merge-multiple',
|
||||||
ArtifactIds = 'artifact-ids'
|
ArtifactIds = 'artifact-ids',
|
||||||
|
UnZip = "unzip"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
|||||||
@ -26,7 +26,8 @@ export async function run(): Promise<void> {
|
|||||||
mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {
|
mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {
|
||||||
required: false
|
required: false
|
||||||
}),
|
}),
|
||||||
artifactIds: core.getInput(Inputs.ArtifactIds, {required: false})
|
artifactIds: core.getInput(Inputs.ArtifactIds, {required: false}),
|
||||||
|
unzip: core.getInput(Inputs.UnZip, {required: false})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputs.path) {
|
if (!inputs.path) {
|
||||||
@ -169,10 +170,15 @@ export async function run(): Promise<void> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadPromises = artifacts.map(artifact => ({
|
const unzip_list = inputs.unzip.split(',');
|
||||||
|
const downloadPromises = artifacts.map(artifact => {
|
||||||
|
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);
|
||||||
|
return {
|
||||||
name: artifact.name,
|
name: artifact.name,
|
||||||
promise: artifactClient.downloadArtifact(artifact.id, {
|
promise: artifactClient.downloadArtifact(artifact.id, {
|
||||||
...options,
|
...options,
|
||||||
|
unzip,
|
||||||
|
artifactName: artifact.name,
|
||||||
path:
|
path:
|
||||||
isSingleArtifactDownload ||
|
isSingleArtifactDownload ||
|
||||||
inputs.mergeMultiple ||
|
inputs.mergeMultiple ||
|
||||||
@ -181,7 +187,8 @@ export async function run(): Promise<void> {
|
|||||||
: path.join(resolvedPath, artifact.name),
|
: path.join(resolvedPath, artifact.name),
|
||||||
expectedHash: artifact.digest
|
expectedHash: artifact.digest
|
||||||
})
|
})
|
||||||
}))
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS)
|
const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS)
|
||||||
for (const chunk of chunkedPromises) {
|
for (const chunk of chunkedPromises) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user