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
{{ message }}
Repository navigation
Commit 8ea3c2c
Browse filesBrowse the repository at this point in the historyBrowse files
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