mirror of
https://github.com/actions/download-artifact.git
synced 2025-12-07 10:17:50 +01:00
Compare commits
1 Commits
v5.0.0
...
426e7e1989
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
426e7e1989 |
4
.github/workflows/check-dist.yml
vendored
4
.github/workflows/check-dist.yml
vendored
@@ -20,10 +20,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node 20
|
- name: Setup Node 24
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 24.x
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
|
|||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -22,10 +22,10 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node 20
|
- name: Setup Node 24
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 24.x
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: npm install
|
- name: npm install
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -8,7 +8,6 @@ See also [upload-artifact](https://github.com/actions/upload-artifact).
|
|||||||
- [v4 - What's new](#v4---whats-new)
|
- [v4 - What's new](#v4---whats-new)
|
||||||
- [Improvements](#improvements)
|
- [Improvements](#improvements)
|
||||||
- [Breaking Changes](#breaking-changes)
|
- [Breaking Changes](#breaking-changes)
|
||||||
- [Note](#note)
|
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Inputs](#inputs)
|
- [Inputs](#inputs)
|
||||||
- [Outputs](#outputs)
|
- [Outputs](#outputs)
|
||||||
@@ -90,7 +89,6 @@ You are welcome to still raise bugs in this repo.
|
|||||||
# When multiple artifacts are matched, this changes the behavior of the destination directories.
|
# 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 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.
|
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
|
||||||
# Note: When downloading a single artifact (by name or ID), it will always be extracted directly to the specified path.
|
|
||||||
# Optional. Default is 'false'
|
# Optional. Default is 'false'
|
||||||
merge-multiple:
|
merge-multiple:
|
||||||
|
|
||||||
@@ -147,8 +145,6 @@ steps:
|
|||||||
|
|
||||||
The `artifact-ids` input allows downloading artifacts using their unique ID rather than name. This is particularly useful when working with immutable artifacts from `actions/upload-artifact@v4` which assigns a unique ID to each artifact.
|
The `artifact-ids` input allows downloading artifacts using their unique ID rather than name. This is particularly useful when working with immutable artifacts from `actions/upload-artifact@v4` which assigns a unique ID to each artifact.
|
||||||
|
|
||||||
Download a single artifact by ID to the current working directory (`$GITHUB_WORKSPACE`):
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
@@ -158,20 +154,6 @@ steps:
|
|||||||
run: ls -R
|
run: ls -R
|
||||||
```
|
```
|
||||||
|
|
||||||
Download a single artifact by ID to a specific directory:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
artifact-ids: 12345
|
|
||||||
path: your/destination/dir
|
|
||||||
- name: Display structure of downloaded files
|
|
||||||
run: ls -R your/destination/dir
|
|
||||||
```
|
|
||||||
|
|
||||||
When downloading a single artifact by ID, the behavior is identical to downloading by name - the artifact contents are extracted directly to the specified path without creating a subdirectory.
|
|
||||||
|
|
||||||
Multiple artifacts can be downloaded by providing a comma-separated list of IDs:
|
Multiple artifacts can be downloaded by providing a comma-separated list of IDs:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -184,7 +166,7 @@ steps:
|
|||||||
run: ls -R path/to/artifacts
|
run: ls -R path/to/artifacts
|
||||||
```
|
```
|
||||||
|
|
||||||
When downloading multiple artifacts by ID, each artifact will be extracted into its own subdirectory named after the artifact (similar to downloading multiple artifacts by name).
|
This will download multiple artifacts to separate directories (similar to downloading multiple artifacts by name).
|
||||||
|
|
||||||
### Download All Artifacts
|
### Download All Artifacts
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as path from 'path'
|
|
||||||
import artifact, {ArtifactNotFoundError} from '@actions/artifact'
|
import artifact, {ArtifactNotFoundError} from '@actions/artifact'
|
||||||
import {run} from '../src/download-artifact'
|
import {run} from '../src/download-artifact'
|
||||||
import {Inputs} from '../src/constants'
|
import {Inputs} from '../src/constants'
|
||||||
@@ -372,38 +371,4 @@ 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'
|
|
||||||
}
|
|
||||||
|
|
||||||
const testPath = '/test/path'
|
|
||||||
mockInputs({
|
|
||||||
[Inputs.Name]: '',
|
|
||||||
[Inputs.Pattern]: '',
|
|
||||||
[Inputs.ArtifactIds]: '456',
|
|
||||||
[Inputs.Path]: testPath
|
|
||||||
})
|
|
||||||
|
|
||||||
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: path.resolve(testPath), // Should be the resolved path directly, not nested
|
|
||||||
expectedHash: mockArtifact.digest
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ outputs:
|
|||||||
download-path:
|
download-path:
|
||||||
description: 'Path of artifact download'
|
description: 'Path of artifact download'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node24'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
6
dist/index.js
vendored
6
dist/index.js
vendored
@@ -118883,9 +118883,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
const downloadPromises = artifacts.map(artifact => ({
|
const downloadPromises = artifacts.map(artifact => ({
|
||||||
name: artifact.name,
|
name: artifact.name,
|
||||||
promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload ||
|
promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple
|
||||||
inputs.mergeMultiple ||
|
|
||||||
artifacts.length === 1
|
|
||||||
? resolvedPath
|
? resolvedPath
|
||||||
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))
|
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))
|
||||||
}));
|
}));
|
||||||
@@ -128960,4 +128958,4 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
|
|||||||
/******/ module.exports = __webpack_exports__;
|
/******/ module.exports = __webpack_exports__;
|
||||||
/******/
|
/******/
|
||||||
/******/ })()
|
/******/ })()
|
||||||
;
|
;
|
||||||
|
|||||||
35
package-lock.json
generated
35
package-lock.json
generated
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^12.12.6",
|
"@types/node": "^24.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@vercel/ncc": "^0.33.4",
|
||||||
"concurrently": "^5.2.0",
|
"concurrently": "^5.2.0",
|
||||||
@@ -28,6 +28,9 @@
|
|||||||
"ts-jest": "^29.2.6",
|
"ts-jest": "^29.2.6",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=24"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@aashutoshrathi/word-wrap": {
|
"node_modules/@aashutoshrathi/word-wrap": {
|
||||||
@@ -2271,9 +2274,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "12.12.6",
|
"version": "24.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
|
||||||
"integrity": "sha512-FjsYUPzEJdGXjwKqSpE0/9QEh6kzhTAeObA54rn6j3rR4C/mzpI9L0KNfoeASSPMMdxIsoJuCLDWcM/rVjIsSA=="
|
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~7.8.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node-fetch": {
|
"node_modules/@types/node-fetch": {
|
||||||
"version": "2.6.9",
|
"version": "2.6.9",
|
||||||
@@ -10192,6 +10199,12 @@
|
|||||||
"node": ">=14.0"
|
"node": ">=14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "7.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||||
|
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/universal-user-agent": {
|
"node_modules/universal-user-agent": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||||
@@ -12471,9 +12484,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.12.6",
|
"version": "24.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
|
||||||
"integrity": "sha512-FjsYUPzEJdGXjwKqSpE0/9QEh6kzhTAeObA54rn6j3rR4C/mzpI9L0KNfoeASSPMMdxIsoJuCLDWcM/rVjIsSA=="
|
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
|
||||||
|
"requires": {
|
||||||
|
"undici-types": "~7.8.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@types/node-fetch": {
|
"@types/node-fetch": {
|
||||||
"version": "2.6.9",
|
"version": "2.6.9",
|
||||||
@@ -18199,6 +18215,11 @@
|
|||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"undici-types": {
|
||||||
|
"version": "7.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||||
|
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="
|
||||||
|
},
|
||||||
"universal-user-agent": {
|
"universal-user-agent": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
"name": "download-artifact",
|
"name": "download-artifact",
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
"description": "Download an Actions Artifact from a workflow run",
|
"description": "Download an Actions Artifact from a workflow run",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=24"
|
||||||
|
},
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@@ -36,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^12.12.6",
|
"@types/node": "^24.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@vercel/ncc": "^0.33.4",
|
||||||
"concurrently": "^5.2.0",
|
"concurrently": "^5.2.0",
|
||||||
|
|||||||
@@ -174,9 +174,7 @@ export async function run(): Promise<void> {
|
|||||||
promise: artifactClient.downloadArtifact(artifact.id, {
|
promise: artifactClient.downloadArtifact(artifact.id, {
|
||||||
...options,
|
...options,
|
||||||
path:
|
path:
|
||||||
isSingleArtifactDownload ||
|
isSingleArtifactDownload || inputs.mergeMultiple
|
||||||
inputs.mergeMultiple ||
|
|
||||||
artifacts.length === 1
|
|
||||||
? resolvedPath
|
? resolvedPath
|
||||||
: path.join(resolvedPath, artifact.name),
|
: path.join(resolvedPath, artifact.name),
|
||||||
expectedHash: artifact.digest
|
expectedHash: artifact.digest
|
||||||
|
|||||||
Reference in New Issue
Block a user