Compare commits

...

35 Commits

Author SHA1 Message Date
48377050ae update 2023-12-07 13:29:22 -08:00
eba2a242da consume latest @actions/toolkit (#461) 2023-12-07 11:53:07 -08:00
500e175644 Merge pull request #460 from actions/robherley/consume-latest-toolkit
Consume latest @actions/artifact
2023-12-04 15:47:37 -05:00
83b889d09d consume latest @actions/artifact 2023-12-04 15:40:37 -05:00
eeb333dcd2 Merge pull request #453 from actions/robherley/more-v4-improvements
More v4 Improvements: adjustable compression level and tweak concurrency
2023-11-21 10:58:16 -05:00
fa39c94ed2 consume latest @actions/artifact from toolkit 2023-11-20 20:56:30 -05:00
59ef34ab24 bump for more logs 2023-11-20 11:28:41 -05:00
20bcd3b8cb add compression level input 2023-11-20 11:08:50 -05:00
aa5cae10db Add artifact-id output to v4-beta (#448)
* Add artifact-id to outputs

* ncc

---------

Co-authored-by: Rob Herley <robherley@github.com>
2023-10-26 12:05:31 -04:00
f87a4089c5 Merge pull request #446 from robherley/v4-beta
[v4-beta] Bump linked artifact toolkit pkg
2023-10-16 14:56:45 -04:00
50ad273a1a bump linked artifact toolkit pkg 2023-10-16 14:30:52 -04:00
0ff37d0dc6 Merge pull request #430 from bethanyj28/main
Create v4-beta
2023-08-24 15:06:41 -04:00
0597a567d0 update dist 2023-08-24 12:03:24 -07:00
0f573694ad bump @actions/artifact to 2.0.0 2023-08-24 11:21:18 -07:00
99700c1456 Update upload-artifact for @actions/artifact@v2 2023-08-24 11:01:45 -07:00
65d862660a chore(github): remove trailing whitespaces (#313)
Signed-off-by: Luís Ferreira <contact@lsferreira.net>

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2023-01-06 09:46:02 -05:00
0b7f8abb15 ci(github): update action/download-artifact from v1 to v3 (#312)
Signed-off-by: Luís Ferreira <contact@lsferreira.net>

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2023-01-05 18:07:55 -05:00
013d2b89ba Create devcontainer for codespaces + update all dev dependencies (#375)
* Create devcontainer for codespaces

* Use node 16 for devcontainer and CI

* Fix node version incompatibility error

* Remove caching

* Add npm build to check-dist

* Remove new caching

* use npm install

* Test node 14

* Update check dist with node 16

* Use node 18.x for check-dist

* Npm install vs CI

* Update package.json scripts

* test

* Remove caching

* npm run test

* testing

* test

* test

* One more test

* Test

* test

* Update everything

* use vercel

* Test

* Update index.js

* Test

* Remove codeql warnings

* Use NPM CI vs install

* Small tweaks to existing workflows
2023-01-05 16:27:11 -05:00
055b8b3f04 Bump Actions NPM dependencies (#374) 2023-01-04 13:55:10 -05:00
7a5d4831f7 ci(github): update action/checkout from v2 to v3 (#315)
Signed-off-by: Luís Ferreira <contact@lsferreira.net>

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2023-01-04 13:44:29 -05:00
e0057a5b76 README: Bump actions/checkout to v3 (#352)
`Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: actions/checkout, actions/checkout`

It's great to have non-deprecated examples.
2023-01-04 13:34:12 -05:00
7fe6c13ac8 Update to latest actions/publish-action (#363)
To avoid Actions core deprecation messages.

https://github.com/actions/publish-action/releases/tag/v0.2.1
2023-01-04 13:21:58 -05:00
83fd05a356 Bump actions-core to v1.10.0 (#356) 2022-10-21 15:17:17 -04:00
3cea537223 Merge pull request #327 from actions/robherley/artifact-1.1.0
Bump @actions/artifact to 1.1.0
2022-05-20 10:28:12 -04:00
849aa7758a nvm use 12 & npm run release 2022-05-19 21:17:44 +00:00
4d3986961d recompile with correct ncc version 2022-05-19 20:46:08 +00:00
2e0d362ec5 bump @actions/artifact to 1.1.0 2022-05-19 20:33:04 +00:00
09a5d6a283 Merge pull request #320 from actions/dependabot/npm_and_yarn/ansi-regex-4.1.1
Bump ansi-regex from 4.1.0 to 4.1.1
2022-04-25 09:59:36 -04:00
189315d910 Bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-25 13:56:12 +00:00
d159c2d80b Merge pull request #297 from actions/dependabot/npm_and_yarn/ajv-6.12.6
Bump ajv from 6.11.0 to 6.12.6
2022-04-25 09:55:27 -04:00
c26a7ba4b5 Bump ajv from 6.11.0 to 6.12.6
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.11.0 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.11.0...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-25 13:50:51 +00:00
6ed6c72922 Merge pull request #303 from actions/dependabot/npm_and_yarn/yargs-parser-13.1.2
Bump yargs-parser from 13.1.1 to 13.1.2
2022-04-25 09:50:11 -04:00
2aeee267b2 Bump yargs-parser from 13.1.1 to 13.1.2
Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 13.1.1 to 13.1.2.
- [Release notes](https://github.com/yargs/yargs-parser/releases)
- [Changelog](https://github.com/yargs/yargs-parser/blob/main/docs/CHANGELOG-full.md)
- [Commits](https://github.com/yargs/yargs-parser/commits)

---
updated-dependencies:
- dependency-name: yargs-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-25 13:47:10 +00:00
0e2226cf92 Merge pull request #311 from actions/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-04-25 09:46:22 -04:00
f29a5d04a6 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 14:50:39 +00:00
19 changed files with 124086 additions and 23026 deletions

View File

@ -0,0 +1,6 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "@actions/upload-artifact",
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-16"
}

View File

@ -4,13 +4,10 @@
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-empty-function": "off"

View File

@ -20,19 +20,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set Node.js 12.x
uses: actions/setup-node@v1
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Move the committed index.js file
run: mv dist/index.js /tmp
- name: Rebuild with tsc
run: npm run build
- name: Rebuild the index.js file
run: npm run release
@ -41,7 +45,7 @@ jobs:
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: index.js

View File

@ -17,11 +17,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
@ -29,7 +29,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -43,4 +43,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@ -22,7 +22,7 @@ jobs:
steps:
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
uses: actions/publish-action@v0.2.1
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -23,12 +23,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set Node.js 12.x
uses: actions/setup-node@v1
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x
cache: 'npm'
- name: Install dependencies
run: npm ci
@ -36,21 +37,21 @@ jobs:
- name: Compile
run: npm run build
- name: npm test
run: npm test
- name: Lint
run: npm run lint
- name: Format
run: npm run format-check
- name: Test
run: npm run test
# Test end-to-end by uploading two artifacts and then downloading them
- name: Create artifact files
run: |
mkdir -p path/to/dir-1
mkdir -p path/to/dir-2
mkdir -p path/to/dir-3
mkdir -p path/to/dir-3
echo "Lorem ipsum dolor sit amet" > path/to/dir-1/file1.txt
echo "Hello world from file #2" > path/to/dir-2/file2.txt
echo "This is a going to be a test for a large enough file that should get compressed with GZip. The @actions/artifact package uses GZip to upload files. This text should have a compression ratio greater than 100% so it should get uploaded using GZip" > path/to/dir-3/gzip.txt
@ -85,11 +86,9 @@ jobs:
path/to/dir-[23]/*
!path/to/dir-3/*.txt
# Verify artifacts. Switch to download-artifact@v2 once it's out of preview
# Download Artifact #1 and verify the correctness of the content
- name: 'Download artifact #1'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v3
with:
name: 'Artifact-A'
path: some/new/path
@ -109,7 +108,7 @@ jobs:
# Download Artifact #2 and verify the correctness of the content
- name: 'Download artifact #2'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v3
with:
name: 'artifact'
path: some/other/path
@ -127,10 +126,10 @@ jobs:
Write-Error "File contents of downloaded artifacts are incorrect"
}
shell: pwsh
# Download Artifact #3 and verify the correctness of the content
- name: 'Download artifact #3'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v3
with:
name: 'GZip-Artifact'
path: gzip/artifact/path
@ -150,7 +149,7 @@ jobs:
shell: pwsh
- name: 'Download artifact #4'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v3
with:
name: 'Multi-Path-Artifact'
path: multi/artifact

View File

@ -1,6 +1,6 @@
---
name: "@actions/artifact"
version: 1.0.0
version: 1.1.1
type: npm
summary:
homepage:

View File

@ -1,6 +1,6 @@
---
name: "@actions/core"
version: 1.2.6
version: 1.10.0
type: npm
summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core

View File

@ -1,6 +1,6 @@
---
name: "@actions/glob"
version: 0.1.0
version: 0.3.0
type: npm
summary: Actions glob lib
homepage: https://github.com/actions/toolkit/tree/master/packages/glob

View File

@ -1,6 +1,6 @@
---
name: "@actions/io"
version: 1.0.2
version: 1.1.2
type: npm
summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/master/packages/io

161
README.md
View File

@ -1,4 +1,6 @@
# Upload-Artifact v3
# Upload-Artifact v4 beta
❗ Not publicly available. If you try to use this version then it will fail. Available only internally at GitHub while in development. Stay tuned for public announcements soon about broader availability❗
This uploads artifacts from your workflow allowing you to share data between jobs and store data once a workflow is complete.
@ -6,19 +8,11 @@ See also [download-artifact](https://github.com/actions/download-artifact).
# What's new
- Easier upload
- Specify a wildcard pattern
- Specify an individual file
- Specify a directory (previously you were limited to only this option)
- Multi path upload
- Use a combination of individual files, wildcards or directories
- Support for excluding certain files
- Upload an artifact without providing a name
- Fix for artifact uploads sometimes not working with containers
- Proxy support out of the box
- Port entire action to typescript from a runner plugin so it is easier to collaborate and accept contributions
🚧 Under construction 🚧
Refer [here](https://github.com/actions/upload-artifact/tree/releases/v1) for the previous version
Big changes coming...
Refer [here](https://github.com/actions/upload-artifact/tree/releases/v3) for the previous version
# Usage
@ -28,13 +22,13 @@ See [action.yml](action.yml)
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: mkdir -p path/to/artifact
- run: echo hello > path/to/artifact/world.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: path/to/artifact/world.txt
@ -43,7 +37,7 @@ steps:
### Upload an Entire Directory
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: path/to/artifact/ # or path/to/artifact
@ -52,7 +46,7 @@ steps:
### Upload using a Wildcard Pattern
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: path/**/[abc]rtifac?/*
@ -61,7 +55,7 @@ steps:
### Upload using Multiple Paths and Exclusions
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: |
@ -97,7 +91,7 @@ The [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/ar
If a path (or paths), result in no files being found for the artifact, the action will succeed but print out a warning. In certain scenarios it may be desirable to fail the action or suppress the warning. The `if-no-files-found` option allows you to customize the behavior of the action if no files are found:
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: path/to/artifact/
@ -109,7 +103,7 @@ If a path (or paths), result in no files being found for the artifact, the actio
To upload artifacts only when the previous step of a job failed, use [`if: failure()`](https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#job-status-check-functions):
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
if: failure()
with:
name: my-artifact
@ -121,7 +115,7 @@ To upload artifacts only when the previous step of a job failed, use [`if: failu
You can upload an artifact without specifying a name
```yaml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
path: path/to/artifact/world.txt
```
@ -130,51 +124,21 @@ If not provided, `artifact` will be used as the default name which will manifest
### Uploading to the same artifact
With the following example, the available artifact (named `artifact` by default if no name is provided) would contain both `world.txt` (`hello`) and `extra-file.txt` (`howdy`):
Unlike earlier versions of `upload-artifact`, uploading to the same artifact via multiple jobs is _not_ supported with `v4`.
```yaml
- run: echo hi > world.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
path: world.txt
- run: echo howdy > extra-file.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
path: extra-file.txt
- run: echo hello > world.txt
- uses: actions/upload-artifact@v3
with:
path: world.txt
```
Each artifact behaves as a file share. Uploading to the same artifact multiple times in the same workflow can overwrite and append already uploaded files:
```yaml
strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 13.x]
steps:
- name: Create a file
run: echo ${{ matrix.node-version }} > my_file.txt
- name: Accidentally upload to the same artifact via multiple jobs
uses: actions/upload-artifact@v3
with:
name: my-artifact
path: ${{ github.workspace }}
```
> **_Warning:_** Be careful when uploading to the same artifact via multiple jobs as artifacts may become corrupted. When uploading a file with an identical name and path in multiple jobs, uploads may fail with 503 errors due to conflicting uploads happening at the same time. Ensure uploads to identical locations to not interfere with each other.
In the above example, four jobs will upload four different files to the same artifact but there will only be one file available when `my-artifact` is downloaded. Each job overwrites what was previously uploaded. To ensure that jobs don't overwrite existing artifacts, use a different name per job:
```yaml
uses: actions/upload-artifact@v3
with:
name: my-artifact ${{ matrix.node-version }}
path: ${{ github.workspace }}
```
Artifact names must be unique since each created artifact is idempotent so multiple jobs cannot modify the same artifact.
### Environment Variables and Tilde Expansion
@ -184,9 +148,9 @@ You can use `~` in the path input as a substitute for `$HOME`. Basic tilde expan
- run: |
mkdir -p ~/new/artifact
echo hello > ~/new/artifact/world.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: Artifacts-V3
name: Artifacts-V4-beta
path: ~/new/**/*
```
@ -199,7 +163,7 @@ Environment variables along with context expressions can also be used for input.
- run: |
mkdir -p ${{ github.workspace }}/artifact
echo hello > ${{ github.workspace }}/artifact/world.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: ${{ env.name }}-name
path: ${{ github.workspace }}/artifact/**/*
@ -213,7 +177,7 @@ For environment variables created in other steps, make sure to use the `env` exp
mkdir testing
echo "This is a file to upload" > testing/file.txt
echo "artifactPath=testing/file.txt" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4-beta
with:
name: artifact
path: ${{ env.artifactPath }} # this will resolve to testing/file.txt at runtime
@ -228,7 +192,7 @@ Artifacts are retained for 90 days by default. You can specify a shorter retenti
run: echo "I won't live long" > my_file.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4-beta
with:
name: my-artifact
path: my_file.txt
@ -237,6 +201,46 @@ Artifacts are retained for 90 days by default. You can specify a shorter retenti
The retention period must be between 1 and 90 inclusive. For more information see [artifact and log retention policies](https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration#artifact-and-log-retention-policy).
## Outputs
If an artifact upload is successful then an `artifact-id` output is available. This ID is a unique identifier that can be used with [Artifact REST APIs](https://docs.github.com/en/rest/actions/artifacts).
### Example output between steps
```yml
- uses: actions/upload-artifact@v4-beta
id: artifact-upload-step
with:
name: my-artifact
path: path/to/artifact/content/
- name: Output artifact ID
run: echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}'
```
### Example output between jobs
```yml
jobs:
job1:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.my-artifact.outputs.artifact-id }}
steps:
- uses: actions/upload-artifact@v4-beta
id: artifact-upload-step
with:
name: my-artifact
path: path/to/artifact/content/
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- env:
OUTPUT1: ${{needs.job1.outputs.output1}}
run: echo "Artifact ID from previous job is $OUTPUT1"
```
## Where does the upload go?
At the bottom of the workflow summary page, there is a dedicated section for artifacts. Here's a screenshot of something you might see:
@ -245,42 +249,7 @@ At the bottom of the workflow summary page, there is a dedicated section for art
There is a trashcan icon that can be used to delete the artifact. This icon will only appear for users who have write permissions to the repository.
The size of the artifact is denoted in bytes. The displayed artifact size denotes the raw uploaded artifact size (the sum of all the individual files uploaded during the workflow run for the artifact), not the compressed size. When you click to download an artifact from the summary page, a compressed zip is created with all the contents of the artifact and the size of the zip that you download may differ significantly from the displayed size. Billing is based on the raw uploaded size and not the size of the zip.
# Limitations
### Zipped Artifact Downloads
During a workflow run, files are uploaded and downloaded individually using the `upload-artifact` and `download-artifact` actions. However, when a workflow run finishes and an artifact is downloaded from either the UI or through the [download api](https://developer.github.com/v3/actions/artifacts/#download-an-artifact), a zip is dynamically created with all the file contents that were uploaded. There is currently no way to download artifacts after a workflow run finishes in a format other than a zip or to download artifact contents individually. One of the consequences of this limitation is that if a zip is uploaded during a workflow run and then downloaded from the UI, there will be a double zip created.
### Permission Loss
: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.
### Case Insensitive Uploads
: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.
### Maintaining file permissions and case sensitive files
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:
```yaml
- name: Tar files
run: tar -cvf my_files.tar /path/to/my/directory
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: my-artifact
path: my_files.tar
```
### Too many uploads resulting in 429 responses
A very minute subset of users who upload a very very large amount of artifacts in a short period of time may see their uploads throttled or fail because of `Request was blocked due to exceeding usage of resource 'DBCPU' in namespace` or `Unable to copy file to server StatusCode=TooManyRequests`.
To reduce the chance of this happening, you can reduce the number of HTTP calls made during artifact upload by zipping or archiving the contents of your artifact before an upload starts. As an example, imagine an artifact with 1000 files (each 10 Kb in size). Without any modification, there would be around 1000 HTTP calls made to upload the artifact. If you zip or archive the artifact beforehand, the number of HTTP calls can be dropped to single digit territory. Measures like this will significantly speed up your upload and prevent uploads from being throttled or in some cases fail.
The size of the artifact is denoted in bytes. The displayed artifact size denotes the size of the zip that `upload-artifact` creates during upload.
## Additional Documentation

View File

@ -1,7 +1,7 @@
name: 'Upload a Build Artifact'
description: 'Upload a build artifact that can be used by subsequent workflow steps'
author: 'GitHub'
inputs:
inputs:
name:
description: 'Artifact name'
default: 'artifact'
@ -23,6 +23,24 @@ inputs:
Minimum 1 day.
Maximum 90 days unless changed from the repository settings page.
compression-level:
description: >
The level of compression for Zlib to be applied to the artifact archive.
The value can range from 0 to 9:
- 0: No compression
- 1: Best speed
- 6: Default compression (same as GNU Gzip)
- 9: Best compression
Higher levels will result in better compression, but will take longer to complete.
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
default: '6'
outputs:
artifact-id:
description: >
A unique identifier for the artifact that was just uploaded. Empty if artifact upload failed.
This ID can be used as input to other APIs to download, delete or get more information about an artifact: https://docs.github.com/en/rest/actions/artifacts
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'

124263
dist/index.js vendored

File diff suppressed because one or more lines are too long

22493
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"release": "ncc build src/upload-artifact.ts && git add -f dist/",
"release": "ncc build src/upload-artifact.ts && git add -f dist/index.js",
"check-all": "concurrently \"npm:format-check\" \"npm:lint\" \"npm:test\" \"npm:build\"",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
@ -29,25 +29,25 @@
},
"homepage": "https://github.com/actions/upload-artifact#readme",
"dependencies": {
"@actions/artifact": "^1.0.0",
"@actions/core": "^1.2.6",
"@actions/glob": "^0.1.0",
"@actions/io": "^1.0.2"
"@actions/artifact": "^2.0.0",
"@actions/core": "^1.10.0",
"@actions/glob": "^0.3.0",
"@actions/io": "^1.1.2"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"@typescript-eslint/parser": "^2.27.0",
"@zeit/ncc": "^0.22.1",
"concurrently": "^5.1.0",
"eslint": "^7.4.0",
"eslint-plugin-github": "^4.1.1",
"eslint-plugin-jest": "^23.8.2",
"glob": "^7.1.6",
"jest": "^27.2.5",
"jest-circus": "^27.2.5",
"prettier": "^2.0.4",
"ts-jest": "^27.0.6",
"typescript": "^3.8.3"
"@types/jest": "^29.2.5",
"@types/node": "^18.11.18",
"@typescript-eslint/parser": "^5.48.0",
"@vercel/ncc": "^0.36.0",
"concurrently": "^7.6.0",
"eslint": "^8.31.0",
"eslint-plugin-github": "^4.6.0",
"eslint-plugin-jest": "^27.2.0",
"glob": "^8.0.3",
"jest": "^29.3.1",
"jest-circus": "^29.3.1",
"prettier": "^2.8.1",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
}
}

View File

@ -1,8 +1,10 @@
/* eslint-disable no-unused-vars */
export enum Inputs {
Name = 'name',
Path = 'path',
IfNoFilesFound = 'if-no-files-found',
RetentionDays = 'retention-days'
RetentionDays = 'retention-days',
CompressionLevel = 'compression-level'
}
export enum NoFileOptions {

View File

@ -36,5 +36,17 @@ export function getInputs(): UploadInputs {
}
}
const compressionLevelStr = core.getInput(Inputs.CompressionLevel)
if (compressionLevelStr) {
inputs.compressionLevel = parseInt(compressionLevelStr)
if (isNaN(inputs.compressionLevel)) {
core.setFailed('Invalid compression-level')
}
if (inputs.compressionLevel < 0 || inputs.compressionLevel > 9) {
core.setFailed('Invalid compression-level. Valid values are 0-9')
}
}
return inputs
}

View File

@ -1,5 +1,7 @@
import * as core from '@actions/core'
import {create, UploadOptions} from '@actions/artifact'
import * as core from '../node_modules/@actions/core/'
import artifact, {
UploadArtifactOptions
} from '../node_modules/@actions/artifact/lib/artifact'
import {findFilesToUpload} from './search'
import {getInputs} from './input-helper'
import {NoFileOptions} from './constants'
@ -37,39 +39,29 @@ async function run(): Promise<void> {
)
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
if (searchResult.filesToUpload.length > 10000) {
core.warning(
`There are over 10,000 files in this artifact, consider creating an archive before upload to improve the upload performance.`
)
}
const artifactClient = create()
const options: UploadOptions = {
continueOnError: false
}
const options: UploadArtifactOptions = {}
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays
}
const uploadResponse = await artifactClient.uploadArtifact(
if (typeof inputs.compressionLevel !== 'undefined') {
options.compressionLevel = inputs.compressionLevel
}
const uploadResponse = await artifact.uploadArtifact(
inputs.artifactName,
searchResult.filesToUpload,
searchResult.rootDirectory,
options
)
if (uploadResponse.failedItems.length > 0) {
core.setFailed(
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
)
} else {
core.info(
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
)
}
core.info(
`Artifact ${inputs.artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
)
core.setOutput('artifact-id', uploadResponse.id)
}
} catch (err) {
core.setFailed(err.message)
} catch (error) {
core.setFailed((error as Error).message)
}
}

View File

@ -20,4 +20,9 @@ export interface UploadInputs {
* Duration after which artifact will expire in days
*/
retentionDays: number
/**
* The level of compression for Zlib to be applied to the artifact archive.
*/
compressionLevel?: number
}