Skip to content

Commit ada9446

Browse files
committedDec 13, 2023
update docs and bump @actions/artifact
1 parent 7eafc8b commit ada9446

File tree

8 files changed

+89599
-68766
lines changed

8 files changed

+89599
-68766
lines changed
 

‎.github/workflows/check-dist.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

27-
- name: Setup Node 16
28-
uses: actions/setup-node@v3
27+
- name: Setup Node 20
28+
uses: actions/setup-node@v4
2929
with:
30-
node-version: 16.x
30+
node-version: 20.x
3131
cache: 'npm'
3232

3333
- name: Install dependencies
@@ -46,7 +46,7 @@ jobs:
4646
id: diff
4747

4848
# If index.js was different than expected, upload the expected version as an artifact
49-
- uses: actions/upload-artifact@v3
49+
- uses: actions/upload-artifact@v4-beta
5050
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
5151
with:
5252
name: dist

‎.github/workflows/licensed.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
name: Check licenses
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- run: npm ci
1818
- name: Install licensed
1919
run: |

‎.github/workflows/test.yml

+8-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- '**.md'
99

1010
jobs:
11-
1211
build:
1312
name: Build
1413

@@ -21,13 +20,12 @@ jobs:
2120

2221
steps:
2322
- name: Checkout
24-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2524

26-
# using node 16 since that is what the latest version of the runner ships with
27-
- name: Setup Node 16
28-
uses: actions/setup-node@v3
25+
- name: Setup Node 20
26+
uses: actions/setup-node@v4
2927
with:
30-
node-version: 16.x
28+
node-version: 20.x
3129
cache: 'npm'
3230

3331
- name: npm install
@@ -40,25 +38,23 @@ jobs:
4038
run: npm run lint
4139

4240
- name: Format
43-
run: npm run format-check
41+
run: npm run format-check
4442

45-
# Test end-to-end by uploading two artifacts and then downloading them
46-
# Once upload-artifact v2 is out of preview, switch over
4743
- name: Create artifacts
4844
run: |
4945
mkdir -p path/to/artifact-A
5046
mkdir -p path/to/artifact-B
5147
echo "Lorem ipsum dolor sit amet" > path/to/artifact-A/file-A.txt
5248
echo "Hello world from file B" > path/to/artifact-B/file-B.txt
53-
49+
5450
- name: Upload artifact A
55-
uses: actions/upload-artifact@v1
51+
uses: actions/upload-artifact@v4-beta
5652
with:
5753
name: 'Artifact-A'
5854
path: path/to/artifact-A
5955

6056
- name: Upload artifact B
61-
uses: actions/upload-artifact@v1
57+
uses: actions/upload-artifact@v4-beta
6258
with:
6359
name: 'Artifact-B'
6460
path: path/to/artifact-B
@@ -110,5 +106,3 @@ jobs:
110106
Write-Error "File contents of downloaded artifacts are incorrect"
111107
}
112108
shell: pwsh
113-
114-

‎README.md

+112-110
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,171 @@
1-
# Download-Artifact v3
1+
# `@actions/download-artifact`
22

3-
This downloads artifacts from your build
3+
Download [Actions Artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) from your Workflow Runs. Internally powered by [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/artifact) package.
44

55
See also [upload-artifact](https://github.com/actions/upload-artifact).
66

7-
# What's new
7+
- [`@actions/download-artifact`](#actionsdownload-artifact)
8+
- [v4 - What's new](#v4---whats-new)
9+
- [Improvements](#improvements)
10+
- [Breaking Changes](#breaking-changes)
11+
- [Usage](#usage)
12+
- [Inputs](#inputs)
13+
- [Outputs](#outputs)
14+
- [Examples](#examples)
15+
- [Download Single Artifact](#download-single-artifact)
16+
- [Download All Artifacts](#download-all-artifacts)
17+
- [Download Artifacts from other Workflow Runs or Repositories](#download-artifacts-from-other-workflow-runs-or-repositories)
18+
- [Limitations](#limitations)
19+
- [Permission Loss](#permission-loss)
820

9-
- Download all artifacts at once
10-
- Output parameter for the download path
11-
- Port entire action to typescript from a runner plugin so it is easier to collaborate and accept contributions
1221

13-
Refer [here](https://github.com/actions/download-artifact/tree/v2) for the previous version
22+
## v4 - What's new
1423

15-
# Usage
24+
> [!IMPORTANT]
25+
> 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).
1626
17-
See [action.yml](action.yml)
27+
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.
1828

19-
# Download a Single Artifact
29+
For more information, see the [`@actions/artifact`](https://github.com/actions/toolkit/tree/main/packages/artifact) documentation.
2030

21-
Basic (download to the current working directory):
22-
```yaml
23-
steps:
24-
- uses: actions/checkout@v3
31+
### Improvements
32+
33+
1. Downloads are significantly faster, upwards of 90% improvement in worst case scenarios.
34+
2. Artifacts can be downloaded from other workflow runs and repositories when supplied with a PAT.
35+
36+
### Breaking Changes
37+
38+
1. On self hosted runners, additional [firewall rules](https://github.com/actions/toolkit/tree/main/packages/artifact#breaking-changes) may be required.
39+
2. Downloading artifacts that were created from `action/upload-artifact@v3` and below are not supported.
40+
41+
## Usage
42+
43+
### Inputs
2544

26-
- uses: actions/download-artifact@v3
45+
```yaml
46+
- uses: actions/download-artifact@v4
2747
with:
28-
name: my-artifact
29-
30-
- name: Display structure of downloaded files
31-
run: ls -R
48+
# Name of the artifact to download.
49+
# Optional. If unspecified, all artifacts for the run are downloaded.
50+
name:
51+
52+
# Destination path. Supports basic tilde expansion.
53+
# Optional. Defaults is $GITHUB_WORKSPACE
54+
path:
55+
56+
# The GitHub token used to authenticate with the GitHub API.
57+
# This is required when downloading artifacts from a different repository or from a different workflow run.
58+
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
59+
github-token:
60+
61+
# The repository owner and the repository name joined together by "/".
62+
# If github-token is specified, this is the repository that artifacts will be downloaded from.
63+
# Optional. Default is ${{ github.repository }}
64+
repository:
65+
66+
# The id of the workflow run where the desired download artifact was uploaded from.
67+
# If github-token is specified, this is the run that artifacts will be downloaded from.
68+
# Optional. Default is ${{ github.repository }}
69+
run-id:
3270
```
3371
34-
Download to a specific directory:
72+
### Outputs
73+
74+
| Name | Description | Example |
75+
| - | - | - |
76+
| `download-path` | Absolute path where the artifact(s) were downloaded | `/tmp/my/download/path` |
77+
78+
## Examples
79+
80+
### Download Single Artifact
81+
82+
Download to current working directory (`$GITHUB_WORKSPACE`):
83+
3584
```yaml
3685
steps:
37-
- uses: actions/checkout@v3
38-
39-
- uses: actions/download-artifact@v3
86+
- uses: actions/download-artifact@v4
4087
with:
4188
name: my-artifact
42-
path: path/to/artifact
43-
4489
- name: Display structure of downloaded files
4590
run: ls -R
46-
working-directory: path/to/artifact
47-
```
48-
49-
Basic tilde expansion is supported for the `path` input:
50-
```yaml
51-
- uses: actions/download-artifact@v3
52-
with:
53-
name: my-artifact
54-
path: ~/download/path
55-
```
56-
57-
## Compatibility between `v1` and `v2`/`v3`
58-
59-
When using `download-artifact@v1`, a directory denoted by the name of the artifact would be created if the `path` input was not provided. All of the contents would be downloaded to this directory.
60-
```
61-
current/working/directory/
62-
my-artifact/
63-
... contents of my-artifact
6491
```
6592

66-
With `v2` and `v3`, when an artifact is specified by the `name` input, there is no longer an extra directory that is created if the `path` input is not provided. All the contents are downloaded to the current working directory.
67-
```
68-
current/working/directory/
69-
... contents of my-artifact
70-
```
93+
Download to a specific directory (also supports `~` expansion):
7194

72-
To maintain the same behavior for `v2` and `v3`, you can set the `path` to the name of the artifact so an extra directory gets created.
73-
```
74-
- uses: actions/download-artifact@v2
95+
```yaml
96+
steps:
97+
- uses: actions/download-artifact@v4
7598
with:
7699
name: my-artifact
77-
path: my-artifact
100+
path: your/destination/dir
101+
- name: Display structure of downloaded files
102+
run: ls -R your/destination/dir
78103
```
79104

80105

81-
# Download All Artifacts
106+
### Download All Artifacts
82107

83108
If the `name` input parameter is not provided, all artifacts will be downloaded. **To differentiate between downloaded artifacts, a directory denoted by the artifacts name will be created for each individual artifact.**
109+
84110
Example, if there are two artifacts `Artifact-A` and `Artifact-B`, and the directory is `etc/usr/artifacts/`, the directory structure will look like this:
111+
85112
```
86-
etc/usr/artifacts/
87-
Artifact-A/
88-
... contents of Artifact-A
89-
Artifact-B/
90-
... contents of Artifact-B
113+
etc/usr/artifacts/
114+
Artifact-A/
115+
... contents of Artifact-A
116+
Artifact-B/
117+
... contents of Artifact-B
91118
```
92119

93-
Download all artifacts to a specific directory
120+
Download all artifacts to the current working directory:
121+
94122
```yaml
95123
steps:
96-
- uses: actions/checkout@v3
97-
98-
- uses: actions/download-artifact@v3
99-
with:
100-
path: path/to/artifacts
101-
124+
- uses: actions/download-artifact@v4
102125
- name: Display structure of downloaded files
103126
run: ls -R
104-
working-directory: path/to/artifacts
105127
```
106128

107-
Download all artifacts to the current working directory
129+
Download all artifacts to a specific directory:
130+
108131
```yaml
109132
steps:
110-
- uses: actions/checkout@v3
111-
112-
- uses: actions/download-artifact@v3
113-
133+
- uses: actions/download-artifact@v4
134+
with:
135+
path: path/to/artifacts
114136
- name: Display structure of downloaded files
115-
run: ls -R
137+
run: ls -R path/to/artifacts
116138
```
117139

118-
# Download path output
140+
### Download Artifacts from other Workflow Runs or Repositories
119141

120-
The `download-path` step output contains information regarding where the artifact was downloaded to. This output can be used for a variety of purposes such as logging or as input to other actions. Be aware of the extra directory that is created if downloading all artifacts (no name specified).
142+
It may be useful to download Artifacts from other workflow runs, or even other repositories. By default, the permissions are scoped so they can only download Artifacts within the current workflow run. To elevate permissions for this scenario, you can specify a `github-token` along with other repository and run identifiers:
121143

122144
```yaml
123145
steps:
124-
- uses: actions/checkout@v3
125-
126-
- uses: actions/download-artifact@v3
127-
id: download
146+
- uses: actions/download-artifact@v4
128147
with:
129-
name: 'my-artifact'
130-
path: path/to/artifacts
131-
132-
- name: 'Echo download path'
133-
run: echo ${{steps.download.outputs.download-path}}
148+
name: my-other-artifact
149+
github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo
150+
repository: actions/toolkit
151+
run-id: 1234
134152
```
135153

136-
> Note: The `id` defined in the `download/artifact` step must match the `id` defined in the `echo` step (i.e `steps.[ID].outputs.download-path`)
137-
138-
# Limitations
154+
## Limitations
139155

140156
### Permission Loss
141157

142-
:exclamation: File permissions are not maintained during artifact upload :exclamation: For example, if you make a file executable using `chmod` and then upload that file, post-download the file is no longer guaranteed to be set as an executable.
143-
144-
### Case Insensitive Uploads
145-
146-
:exclamation: File uploads are case insensitive :exclamation: If you upload `A.txt` and `a.txt` with the same root path, only a single file will be saved and available during download.
147-
148-
### Maintaining file permissions and case sensitive files
158+
File permissions are not maintained during artifact upload. All directories will have `755` and all files will have `644`. For example, if you make a file executable using `chmod` and then upload that file, post-download the file is no longer guaranteed to be set as an executable.
149159

150-
If file permissions and case sensitivity are required, you can `tar` all of your files together before artifact upload. Post download, the `tar` file will maintain file permissions and case sensitivity.
160+
If you must preserve permissions, you can `tar` all of your files together before artifact upload. Post download, the `tar` file will maintain file permissions and case sensitivity.
151161

152162
```yaml
153-
- name: 'Tar files'
154-
run: tar -cvf my_files.tar /path/to/my/directory
155-
156-
- name: 'Upload Artifact'
157-
uses: actions/upload-artifact@v2
158-
with:
159-
name: my-artifact
160-
path: my_files.tar
161-
```
162-
163-
# @actions/artifact package
164-
165-
Internally the [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/artifact) NPM package is used to interact with artifacts. You can find additional documentation there along with all the source code related to artifact download.
166-
167-
# License
163+
- name: 'Tar files'
164+
run: tar -cvf my_files.tar /path/to/my/directory
168165
169-
The scripts and documentation in this project are released under the [MIT License](LICENSE)
166+
- name: 'Upload Artifact'
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: my-artifact
170+
path: my_files.tar
171+
```

‎action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ description: 'Download a build artifact that was previously uploaded in the work
33
author: 'GitHub'
44
inputs:
55
name:
6-
description: 'Artifact name'
6+
description: 'Name of the artifact to download. If unspecified, all artifacts for the run are downloaded'
77
required: false
88
path:
9-
description: 'Destination path'
9+
description: 'Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE'
1010
required: false
1111
github-token:
1212
description: 'The GitHub token used to authenticate with the GitHub API.

0 commit comments

Comments
 (0)