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
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`.
8
9
@@ -142,3 +143,64 @@ jobs:
142
143
```
143
144
144
145
Note that this will create an _entirely_ new Artifact, with a different ID from the previous.
146
+
147
+
## Merging multiple artifacts
148
+
149
+
In `v3`, multiple uploads from multiple jobs could be done to the same Artifact. This would result in a single archive, which could be useful for sending to upstream systems outside of Actions via API or UI downloads.
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](../merge/README.md).
Note: this actions can only merge artifacts created with actions/upload-artifact@v4+
17
21
22
+
This sub-action is a helper to merge multiple artifacts after they are created. To do so, it will download multiple artifacts to a temporary directory and reupload them as a single artifact.
23
+
24
+
For most cases, this may not be the most efficient solution. See [the migration docs](../docs/MIGRATION.md#multiple-uploads-to-the-same-named-artifact) on how to download multiple artifacts to the same directory on a runner. This action should only be necessary for cases where multiple artifacts will need to be downloaded outside the runner environment, like downloads via the UI or REST API.
25
+
18
26
### Inputs
19
27
20
28
```yaml
@@ -60,4 +68,133 @@ Note: this actions can only merge artifacts created with actions/upload-artifact
60
68
61
69
## Examples
62
70
63
-
TODO(robherley): add examples
71
+
For each of these examples, assume we have a prior job matrix that generates three artifacts: `my-artifact-a`, `my-artifact-b` and `my-artifact-c`.
Each of the following examples will use the `needs: upload` as a prerequesite before any merging operations.
95
+
96
+
### Combining all artifacts in a workflow run
97
+
98
+
By default (with no inputs), calling this action will take all the artifacts in the workflow run and combined them into a single artifact called `merged-artifacts`:
99
+
100
+
```yaml
101
+
jobs:
102
+
# ... <upload job> ...
103
+
merge:
104
+
runs-on: ubuntu-latest
105
+
needs: upload
106
+
steps:
107
+
- name: Merge Artifacts
108
+
uses: actions/upload-artifact/merge@v4
109
+
```
110
+
111
+
This will result in an artifact called `merged-artifacts` with the following content:
112
+
113
+
```
114
+
.
115
+
∟ file-a.txt
116
+
∟ file-b.txt
117
+
∟ file-c.txt
118
+
```
119
+
120
+
To change the name of the artifact and filter on what artifacts are added, you can use the `name` and `pattern` inputs:
121
+
122
+
```yaml
123
+
jobs:
124
+
# ... <upload job> ...
125
+
merge:
126
+
runs-on: ubuntu-latest
127
+
needs: upload
128
+
steps:
129
+
- name: Merge Artifacts
130
+
uses: actions/upload-artifact/merge@v4
131
+
with:
132
+
name: my-amazing-merged-artifact
133
+
pattern: my-artifact-*
134
+
```
135
+
136
+
### Prefix directories in merged artifact
137
+
138
+
To prevent overwriting files in artifacts that may have the same name, you can use the `separate-directories` to prefix the extracted files with directories (named after the original artifact):
139
+
140
+
```yaml
141
+
jobs:
142
+
# ... <upload job> ...
143
+
merge:
144
+
runs-on: ubuntu-latest
145
+
needs: upload
146
+
steps:
147
+
- name: Merge Artifacts
148
+
uses: actions/upload-artifact/merge@v4
149
+
with:
150
+
separate-directories: true
151
+
```
152
+
153
+
This will result in the following artifact structure:
154
+
155
+
```
156
+
.
157
+
∟ my-artifact-a
158
+
∟ file-a.txt
159
+
∟ my-artifact-b
160
+
∟ file-b.txt
161
+
∟ my-artifact-c
162
+
∟ file-c.txt
163
+
```
164
+
165
+
### Deleting artifacts after merge
166
+
167
+
After merge, the old artifacts may no longer be required. To automatically delete them after they are merged into a new artifact, you can use `delete-merged` like so:
168
+
169
+
```yaml
170
+
jobs:
171
+
# ... <upload job> ...
172
+
merge:
173
+
runs-on: ubuntu-latest
174
+
needs: upload
175
+
steps:
176
+
- name: Merge Artifacts
177
+
uses: actions/upload-artifact/merge@v4
178
+
with:
179
+
delete-merged: true
180
+
```
181
+
182
+
After this runs, the matching artifact (`my-artifact-a`, `my-artifact-b` and `my-artifact-c`) will be merged.
183
+
184
+
### Retention and Compression Level
185
+
186
+
Similar to actions/upload-artifact, both [`retention-days`](../README.md#retention-period) and [`compression-level`](../README.md#altering-compressions-level-speed-v-size) are supported:
0 commit comments