You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ See also [upload-artifact](https://github.com/actions/upload-artifact).
13
13
-[Outputs](#outputs)
14
14
-[Examples](#examples)
15
15
-[Download Single Artifact](#download-single-artifact)
16
+
-[Download Artifacts by ID](#download-artifacts-by-id)
16
17
-[Download All Artifacts](#download-all-artifacts)
17
18
-[Download multiple (filtered) Artifacts to the same directory](#download-multiple-filtered-artifacts-to-the-same-directory)
18
19
-[Download Artifacts from other Workflow Runs or Repositories](#download-artifacts-from-other-workflow-runs-or-repositories)
@@ -53,6 +54,11 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
53
54
# Optional.
54
55
name:
55
56
57
+
# IDs of the artifacts to download, comma-separated.
58
+
# Either inputs `artifact-ids` or `name` can be used, but not both.
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.
129
+
130
+
```yaml
131
+
steps:
132
+
- uses: actions/download-artifact@v4
133
+
with:
134
+
artifact-ids: 12345
135
+
- name: Display structure of downloaded files
136
+
run: ls -R
137
+
```
138
+
139
+
Multiple artifacts can be downloaded by providing a comma-separated list of IDs:
140
+
141
+
```yaml
142
+
steps:
143
+
- uses: actions/download-artifact@v4
144
+
with:
145
+
artifact-ids: 12345,67890
146
+
path: path/to/artifacts
147
+
- name: Display structure of downloaded files
148
+
run: ls -R path/to/artifacts
149
+
```
150
+
151
+
This will download multiple artifacts to separate directories (similar to downloading multiple artifacts by name).
-[Working with Immutable Artifacts](#working-with-immutable-artifacts)
7
8
8
9
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`.
9
10
@@ -207,3 +208,38 @@ jobs:
207
208
```
208
209
209
210
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](https://github.com/actions/upload-artifact/blob/main/merge/README.md).
211
+
212
+
## Working with Immutable Artifacts
213
+
214
+
In `v4`, artifacts are immutable by default and each artifact gets a unique ID when uploaded. When an artifact with the same name is uploaded again (with or without `overwrite: true`), it gets a new artifact ID.
215
+
216
+
To take advantage of this immutability for security purposes (to avoid potential TOCTOU issues where an artifact might be replaced between upload and download), the new `artifact-ids` input allows you to download artifacts by their specific ID rather than by name:
217
+
218
+
```yaml
219
+
jobs:
220
+
upload:
221
+
runs-on: ubuntu-latest
222
+
steps:
223
+
- name: Create a file
224
+
run: echo "hello world" > my-file.txt
225
+
- name: Upload Artifact
226
+
id: upload
227
+
uses: actions/upload-artifact@v4
228
+
with:
229
+
name: my-artifact
230
+
path: my-file.txt
231
+
# The upload step outputs the artifact ID
232
+
- name: Print Artifact ID
233
+
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"
234
+
download:
235
+
needs: upload
236
+
runs-on: ubuntu-latest
237
+
steps:
238
+
- name: Download Artifact by ID
239
+
uses: actions/download-artifact@v4
240
+
with:
241
+
# Use the artifact ID directly, not the name, to ensure you get exactly the artifact you expect
0 commit comments