Skip to content

Commit ba34d96

Browse files
committed
Added initial github action
1 parent ffbf964 commit ba34d96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+8014
-0
lines changed

Diff for: .action/artifact/README.md

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# `@actions/artifact`
2+
3+
## Usage
4+
5+
You can use this package to interact with the actions artifacts.
6+
- [Upload an Artifact](#Upload-an-Artifact)
7+
- [Download a Single Artifact](#Download-a-Single-Artifact)
8+
- [Download All Artifacts](#Download-all-Artifacts)
9+
- [Additional Documentation](#Additional-Documentation)
10+
- [Contributions](#Contributions)
11+
12+
Relative paths and absolute paths are both allowed. Relative paths are rooted against the current working directory.
13+
14+
## Upload an Artifact
15+
16+
Method Name: `uploadArtifact`
17+
18+
#### Inputs
19+
- `name`
20+
- The name of the artifact that is being uploaded
21+
- Required
22+
- `files`
23+
- A list of file paths that describe what should be uploaded as part of the artifact
24+
- If a path is provided that does not exist, an error will be thrown
25+
- Can be absolute or relative. Internally everything is normalized and resolved
26+
- Required
27+
- `rootDirectory`
28+
- A file path that denotes the root directory of the files being uploaded. This path is used to strip the paths provided in `files` to control how they are uploaded and structured
29+
- If a file specified in `files` is not in the `rootDirectory`, an error will be thrown
30+
- Required
31+
- `options`
32+
- Extra options that allow for the customization of the upload behavior
33+
- Optional
34+
35+
#### Available Options
36+
37+
- `continueOnError`
38+
- Indicates if the artifact upload should continue in the event a file fails to upload. If there is a error during upload, a partial artifact will always be created and available for download at the end. The `size` reported will be the amount of storage that the user or org will be charged for the partial artifact.
39+
- If set to `false`, and an error is encountered, all other uploads will stop and any files that were queued will not be attempted to be uploaded. The partial artifact available will only include files up until the failure.
40+
- If set to `true` and an error is encountered, the failed file will be skipped and ignored and all other queued files will be attempted to be uploaded. There will be an artifact available for download at the end with everything excluding the file that failed to upload
41+
- Optional, defaults to `true` if not specified
42+
43+
#### Example using Absolute File Paths
44+
45+
```js
46+
const artifact = require('@actions/artifact');
47+
const artifactClient = artifact.create()
48+
const artifactName = 'my-artifact';
49+
const files = [
50+
'/home/user/files/plz-upload/file1.txt',
51+
'/home/user/files/plz-upload/file2.txt',
52+
'/home/user/files/plz-upload/dir/file3.txt'
53+
]
54+
const rootDirectory = '/home/user/files/plz-upload'
55+
const options = {
56+
continueOnError: true
57+
}
58+
59+
const uploadResult = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options)
60+
```
61+
62+
#### Example using Relative File Paths
63+
```js
64+
// Assuming the current working directory is /home/user/files/plz-upload
65+
const artifact = require('@actions/artifact');
66+
const artifactClient = artifact.create()
67+
const artifactName = 'my-artifact';
68+
const files = [
69+
'file1.txt',
70+
'file2.txt',
71+
'dir/file3.txt'
72+
]
73+
74+
const rootDirectory = '.' // Also possible to use __dirname
75+
const options = {
76+
continueOnError: false
77+
}
78+
79+
const uploadResponse = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options)
80+
```
81+
82+
#### Upload Result
83+
84+
The returned `UploadResponse` will contain the following information
85+
86+
- `artifactName`
87+
- The name of the artifact that was uploaded
88+
- `artifactItems`
89+
- A list of all files that describe what is uploaded if there are no errors encountered. Usually this will be equal to the inputted `files` with the exception of empty directories (will not be uploaded)
90+
- `size`
91+
- Total size of the artifact that was uploaded in bytes
92+
- `failedItems`
93+
- A list of items that were not uploaded successfully (this will include queued items that were not uploaded if `continueOnError` is set to false). This is a subset of `artifactItems`
94+
95+
## Download a Single Artifact
96+
97+
Method Name: `downloadArtifact`
98+
99+
#### Inputs
100+
- `name`
101+
- The name of the artifact to download
102+
- Required
103+
- `path`
104+
- Path that denotes where the artifact will be downloaded to
105+
- Optional. Defaults to the GitHub workspace directory(`$GITHUB_WORKSPACE`) if not specified
106+
- `options`
107+
- Extra options that allow for the customization of the download behavior
108+
- Optional
109+
110+
111+
#### Available Options
112+
113+
- `createArtifactFolder`
114+
- Specifies if a folder (the artifact name) is created for the artifact that is downloaded (contents downloaded into this folder),
115+
- Optional. Defaults to false if not specified
116+
117+
#### Example
118+
119+
```js
120+
const artifact = require('@actions/artifact');
121+
const artifactClient = artifact.create()
122+
const artifactName = 'my-artifact';
123+
const path = 'some/directory'
124+
const options = {
125+
createArtifactFolder: false
126+
}
127+
128+
const downloadResponse = await artifactClient.downloadArtifact(artifactName, path, options)
129+
130+
// Post download, the directory structure will look like this
131+
/some
132+
/directory
133+
/file1.txt
134+
/file2.txt
135+
/dir
136+
/file3.txt
137+
138+
// If createArtifactFolder is set to true, the directory structure will look like this
139+
/some
140+
/directory
141+
/my-artifact
142+
/file1.txt
143+
/file2.txt
144+
/dir
145+
/file3.txt
146+
```
147+
148+
#### Download Response
149+
150+
The returned `DownloadResponse` will contain the following information
151+
152+
- `artifactName`
153+
- The name of the artifact that was downloaded
154+
- `downloadPath`
155+
- The full Path to where the artifact was downloaded
156+
157+
158+
## Download All Artifacts
159+
160+
Method Name: `downloadAllArtifacts`
161+
162+
#### Inputs
163+
- `path`
164+
- Path that denotes where the artifact will be downloaded to
165+
- Optional. Defaults to the GitHub workspace directory(`$GITHUB_WORKSPACE`) if not specified
166+
167+
```js
168+
const artifact = require('@actions/artifact');
169+
const artifactClient = artifact.create();
170+
const downloadResponse = await artifactClient.downloadAllArtifacts();
171+
172+
// output result
173+
for (response in downloadResponse) {
174+
console.log(response.artifactName);
175+
console.log(response.downloadPath);
176+
}
177+
```
178+
179+
Because there are multiple artifacts, an extra directory (denoted by the name of the artifact) will be created for each artifact in the path. With 2 artifacts(`my-artifact-1` and `my-artifact-2` for example) and the default path, the directory structure will be as follows:
180+
```js
181+
/GITHUB_WORKSPACE
182+
/my-artifact-1
183+
/ .. contents of `my-artifact-1`
184+
/my-artifact-2
185+
/ .. contents of `my-artifact-2`
186+
```
187+
188+
#### Download Result
189+
190+
An array will be returned that describes the results for downloading all artifacts. The number of items in the array indicates the number of artifacts that were downloaded.
191+
192+
Each artifact will have the same `DownloadResponse` as if it was individually downloaded
193+
- `artifactName`
194+
- The name of the artifact that was downloaded
195+
- `downloadPath`
196+
- The full Path to where the artifact was downloaded
197+
198+
## Additional Documentation
199+
200+
Check out [additional-information](docs/additional-information.md) for extra documentation around usage, restrictions and behavior.
201+
202+
Check out [implementation-details](docs/implementation-details.md) for extra information about the implementation of this package.
203+
204+
## Contributions
205+
206+
See [contributor guidelines](https://github.com/actions/toolkit/blob/master/.github/CONTRIBUTING.md) for general guidelines and information about toolkit contributions.
207+
208+
For contributions related to this package, see [artifact contributions](CONTRIBUTIONS.md) for more information.

Diff for: .action/artifact/lib/__mocks__/internal-config-variables.js

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .action/artifact/lib/artifact-client.js

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)