mirror of
https://github.com/actions/download-artifact.git
synced 2025-12-07 18:27:49 +01:00
Compare commits
1 Commits
salmanmkc/
...
426e7e1989
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
426e7e1989 |
8
.github/workflows/check-dist.yml
vendored
8
.github/workflows/check-dist.yml
vendored
@@ -18,12 +18,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node 20
|
- name: Setup Node 24
|
||||||
uses: actions/setup-node@v5
|
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@v5
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
|
|||||||
2
.github/workflows/licensed.yml
vendored
2
.github/workflows/licensed.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v4
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Install licensed
|
- name: Install licensed
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checking out
|
- name: Checking out
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v4
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@0.0.3
|
uses: actions/publish-immutable-action@0.0.3
|
||||||
|
|||||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@@ -20,12 +20,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node 20
|
- name: Setup Node 24
|
||||||
uses: actions/setup-node@v5
|
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
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -5,11 +5,9 @@ Download [Actions Artifacts](https://docs.github.com/en/actions/using-workflows/
|
|||||||
See also [upload-artifact](https://github.com/actions/upload-artifact).
|
See also [upload-artifact](https://github.com/actions/upload-artifact).
|
||||||
|
|
||||||
- [`@actions/download-artifact`](#actionsdownload-artifact)
|
- [`@actions/download-artifact`](#actionsdownload-artifact)
|
||||||
- [v5 - What's new](#v5---whats-new)
|
|
||||||
- [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)
|
||||||
@@ -22,24 +20,11 @@ See also [upload-artifact](https://github.com/actions/upload-artifact).
|
|||||||
- [Limitations](#limitations)
|
- [Limitations](#limitations)
|
||||||
- [Permission Loss](#permission-loss)
|
- [Permission Loss](#permission-loss)
|
||||||
|
|
||||||
## v5 - What's new
|
|
||||||
|
|
||||||
Previously, **single artifact downloads** behaved differently depending on how you specified the artifact:
|
|
||||||
|
|
||||||
- **By name**: `name: my-artifact` → extracted to `path/` (direct)
|
|
||||||
- **By ID**: `artifact-ids: 12345` → extracted to `path/my-artifact/` (nested)
|
|
||||||
|
|
||||||
Now both methods are consistent:
|
|
||||||
|
|
||||||
- **By name**: `name: my-artifact` → extracted to `path/` (unchanged)
|
|
||||||
- **By ID**: `artifact-ids: 12345` → extracted to `path/` (updated - now direct)
|
|
||||||
|
|
||||||
Note: This change also applies to patterns that only match a single artifact.
|
|
||||||
|
|
||||||
## v4 - What's new
|
## v4 - What's new
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> download-artifact@v4+ is not currently supported on GitHub Enterprise Server (GHES) yet. If you are on GHES, you must use [v3](https://github.com/actions/download-artifact/releases/tag/v3).
|
> download-artifact@v4+ is not currently supported on GHES yet. If you are on GHES, you must use [v3](https://github.com/actions/download-artifact/releases/tag/v3).
|
||||||
|
|
||||||
The release of upload-artifact@v4 and download-artifact@v4 are major changes to the backend architecture of Artifacts. They have numerous performance and behavioral improvements.
|
The release of upload-artifact@v4 and download-artifact@v4 are major changes to the backend architecture of Artifacts. They have numerous performance and behavioral improvements.
|
||||||
|
|
||||||
@@ -80,7 +65,7 @@ You are welcome to still raise bugs in this repo.
|
|||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
# Name of the artifact to download.
|
# Name of the artifact to download.
|
||||||
# If unspecified, all artifacts for the run are downloaded.
|
# If unspecified, all artifacts for the run are downloaded.
|
||||||
@@ -104,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:
|
||||||
|
|
||||||
@@ -138,7 +122,7 @@ Download to current working directory (`$GITHUB_WORKSPACE`):
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
@@ -149,7 +133,7 @@ Download to a specific directory (also supports `~` expansion):
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: your/destination/dir
|
path: your/destination/dir
|
||||||
@@ -161,36 +145,20 @@ 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@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
artifact-ids: 12345
|
artifact-ids: 12345
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R
|
run: ls -R
|
||||||
```
|
```
|
||||||
|
|
||||||
Download a single artifact by ID to a specific directory:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v5
|
|
||||||
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
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
artifact-ids: 12345,67890
|
artifact-ids: 12345,67890
|
||||||
path: path/to/artifacts
|
path: path/to/artifacts
|
||||||
@@ -198,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
|
||||||
|
|
||||||
@@ -218,7 +186,7 @@ Download all artifacts to the current working directory:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R
|
run: ls -R
|
||||||
```
|
```
|
||||||
@@ -227,7 +195,7 @@ Download all artifacts to a specific directory:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: path/to/artifacts
|
path: path/to/artifacts
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
@@ -238,7 +206,7 @@ To download them to the _same_ directory:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: path/to/artifacts
|
path: path/to/artifacts
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
@@ -278,7 +246,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download All Artifacts
|
- name: Download All Artifacts
|
||||||
uses: actions/download-artifact@v5
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: my-artifact
|
path: my-artifact
|
||||||
pattern: my-artifact-*
|
pattern: my-artifact-*
|
||||||
@@ -301,7 +269,7 @@ It may be useful to download Artifacts from other workflow runs, or even other r
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: my-other-artifact
|
name: my-other-artifact
|
||||||
github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo
|
github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo
|
||||||
|
|||||||
@@ -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
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
215584
dist/index.js
vendored
215584
dist/index.js
vendored
File diff suppressed because one or more lines are too long
14871
package-lock.json
generated
14871
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -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",
|
||||||
@@ -29,14 +32,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/download-artifact#readme",
|
"homepage": "https://github.com/actions/download-artifact#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "file:../packages/artifact",
|
"@actions/artifact": "^2.3.2",
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"minimatch": "^9.0.3"
|
"minimatch": "^9.0.3"
|
||||||
},
|
},
|
||||||
"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",
|
||||||
@@ -48,8 +51,5 @@
|
|||||||
"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"
|
||||||
},
|
|
||||||
"overrides": {
|
|
||||||
"uri-js": "npm:uri-js-replace@^1.0.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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