mirror of
https://github.com/actions/download-artifact.git
synced 2025-08-14 12:45:05 +00:00
fix download path logic when downloading a single artifact by id
This commit is contained in:
parent
448e3f862a
commit
fff8c148a8
@ -371,4 +371,37 @@ describe('download', () => {
|
|||||||
"Inputs 'name' and 'artifact-ids' cannot be used together. Please specify only one."
|
"Inputs 'name' and 'artifact-ids' cannot be used together. Please specify only one."
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('downloads single artifact by ID to same path as by name', async () => {
|
||||||
|
const mockArtifact = {
|
||||||
|
id: 456,
|
||||||
|
name: 'test-artifact',
|
||||||
|
size: 1024,
|
||||||
|
digest: 'def456'
|
||||||
|
}
|
||||||
|
|
||||||
|
mockInputs({
|
||||||
|
[Inputs.Name]: '',
|
||||||
|
[Inputs.Pattern]: '',
|
||||||
|
[Inputs.ArtifactIds]: '456',
|
||||||
|
[Inputs.Path]: '/test/path'
|
||||||
|
})
|
||||||
|
|
||||||
|
jest.spyOn(artifact, 'listArtifacts').mockImplementation(() =>
|
||||||
|
Promise.resolve({
|
||||||
|
artifacts: [mockArtifact]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
await run()
|
||||||
|
|
||||||
|
// Verify it downloads directly to the specified path (not nested in artifact name subdirectory)
|
||||||
|
expect(artifact.downloadArtifact).toHaveBeenCalledWith(
|
||||||
|
456,
|
||||||
|
expect.objectContaining({
|
||||||
|
path: '/test/path', // Should be the resolved path directly, not /test/path/test-artifact
|
||||||
|
expectedHash: mockArtifact.digest
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -174,7 +174,9 @@ export async function run(): Promise<void> {
|
|||||||
promise: artifactClient.downloadArtifact(artifact.id, {
|
promise: artifactClient.downloadArtifact(artifact.id, {
|
||||||
...options,
|
...options,
|
||||||
path:
|
path:
|
||||||
isSingleArtifactDownload || inputs.mergeMultiple
|
isSingleArtifactDownload ||
|
||||||
|
inputs.mergeMultiple ||
|
||||||
|
artifacts.length === 1
|
||||||
? resolvedPath
|
? resolvedPath
|
||||||
: path.join(resolvedPath, artifact.name),
|
: path.join(resolvedPath, artifact.name),
|
||||||
expectedHash: artifact.digest
|
expectedHash: artifact.digest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user