Skip to content

Commit 7f16e37

Browse files
committed
add migrations docs
1 parent 3530730 commit 7f16e37

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ For more information, see the [`@actions/artifact`](https://github.com/actions/t
5656

5757
3. Limit of Artifacts for an individual job. Each job in a workflow run now has a limit of 10 artifacts.
5858

59+
For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
60+
5961
## Usage
6062

6163
### Inputs

docs/MIGRATION.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Migration
2+
3+
- [Migration](#migration)
4+
- [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact)
5+
6+
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`.
7+
8+
## Multiple uploads to the same named Artifact
9+
10+
In `v3`, Artifacts are _mutable_ so it's possible to write workflow scenarios where multiple jobs upload to the same Artifact like so:
11+
12+
```yaml
13+
jobs:
14+
upload:
15+
strategy:
16+
matrix:
17+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.runs-on }}
19+
steps:
20+
- name: Create a File
21+
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
22+
- name: Upload Artifact
23+
uses: actions/upload-artifact@v3
24+
with:
25+
name: my-artifact # NOTE: same artifact name
26+
path: file-${{ matrix.runs-on }}.txt
27+
download:
28+
needs: upload
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Download All Artifacts
32+
uses: actions/download-artifact@v3
33+
with:
34+
path: my-artifact
35+
- run: ls -R my-artifact
36+
```
37+
38+
This results in a directory like so:
39+
40+
```
41+
my-artifact/
42+
file-macos-latest.txt
43+
file-ubuntu-latest.txt
44+
file-windows-latest.txt
45+
```
46+
47+
In v4, Artifacts are immutable (unless deleted). So you must change each of the uploaded Artifacts to have a different name and filter the downloads by name to achieve the same effect:
48+
49+
```diff
50+
jobs:
51+
upload:
52+
strategy:
53+
matrix:
54+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
55+
runs-on: ${{ matrix.runs-on }}
56+
steps:
57+
- name: Create a File
58+
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
59+
- name: Upload Artifact
60+
- uses: actions/upload-artifact@v3
61+
+ uses: actions/upload-artifact@v4
62+
with:
63+
- name: my-artifact
64+
+ name: my-artifact-${{ matrix.runs-on }}
65+
path: file-${{ matrix.runs-on }}.txt
66+
download:
67+
needs: upload
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Download All Artifacts
71+
- uses: actions/download-artifact@v3
72+
+ uses: actions/download-artifact@v4
73+
with:
74+
path: my-artifact
75+
+ pattern: my-artifact-*
76+
+ merge-multiple: true
77+
- run: ls -R my-artifact
78+
```
79+
80+
In `v4`, the new `pattern:` input will filter the downloaded Artifacts to match the name specified. The new `merge-multiple:` input will support downloading multiple Artifacts to the same directory. If the files within the Artifacts have the same name, the last writer wins.

0 commit comments

Comments
 (0)