mirror of
https://github.com/actions/upload-artifact.git
synced 2025-06-14 15:57:12 +02:00
Compare commits
35 Commits
v3.0.0
...
jtamsut/up
Author | SHA1 | Date | |
---|---|---|---|
48377050ae | |||
eba2a242da | |||
500e175644 | |||
83b889d09d | |||
eeb333dcd2 | |||
fa39c94ed2 | |||
59ef34ab24 | |||
20bcd3b8cb | |||
aa5cae10db | |||
f87a4089c5 | |||
50ad273a1a | |||
0ff37d0dc6 | |||
0597a567d0 | |||
0f573694ad | |||
99700c1456 | |||
65d862660a | |||
0b7f8abb15 | |||
013d2b89ba | |||
055b8b3f04 | |||
7a5d4831f7 | |||
e0057a5b76 | |||
7fe6c13ac8 | |||
83fd05a356 | |||
3cea537223 | |||
849aa7758a | |||
4d3986961d | |||
2e0d362ec5 | |||
09a5d6a283 | |||
189315d910 | |||
d159c2d80b | |||
c26a7ba4b5 | |||
6ed6c72922 | |||
2aeee267b2 | |||
0e2226cf92 | |||
f29a5d04a6 |
6
.devcontainer/devcontainer.json
Normal file
6
.devcontainer/devcontainer.json
Normal 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"
|
||||||
|
}
|
@ -4,13 +4,10 @@
|
|||||||
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
|
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:import/errors",
|
"plugin:import/errors",
|
||||||
"plugin:import/warnings",
|
"plugin:import/warnings",
|
||||||
"plugin:import/typescript",
|
"plugin:import/typescript",
|
||||||
"plugin:prettier/recommended",
|
"plugin:prettier/recommended"
|
||||||
"prettier/@typescript-eslint"
|
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-empty-function": "off"
|
"@typescript-eslint/no-empty-function": "off"
|
||||||
|
16
.github/workflows/check-dist.yml
vendored
16
.github/workflows/check-dist.yml
vendored
@ -20,19 +20,23 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 12.x
|
- name: Setup Node 16
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Move the committed index.js file
|
- name: Move the committed index.js file
|
||||||
run: mv dist/index.js /tmp
|
run: mv dist/index.js /tmp
|
||||||
|
|
||||||
|
- name: Rebuild with tsc
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
- name: Rebuild the index.js file
|
- name: Rebuild the index.js file
|
||||||
run: npm run release
|
run: npm run release
|
||||||
|
|
||||||
@ -41,7 +45,7 @@ jobs:
|
|||||||
id: diff
|
id: diff
|
||||||
|
|
||||||
# If index.js was different than expected, upload the expected version as an artifact
|
# 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' }}
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
with:
|
with:
|
||||||
name: index.js
|
name: index.js
|
||||||
|
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@ -17,11 +17,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- 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
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
# with:
|
# with:
|
||||||
# languages: go, javascript, csharp, python, cpp, java
|
# languages: go, javascript, csharp, python, cpp, java
|
||||||
@ -29,7 +29,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# 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)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@ -43,4 +43,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
id: update-major-tag
|
id: update-major-tag
|
||||||
uses: actions/publish-action@v0.1.0
|
uses: actions/publish-action@v0.2.1
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
@ -23,12 +23,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 12.x
|
- name: Setup Node 16
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
@ -36,21 +37,21 @@ jobs:
|
|||||||
- name: Compile
|
- name: Compile
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: npm test
|
|
||||||
run: npm test
|
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
|
|
||||||
- name: Format
|
- name: Format
|
||||||
run: npm run format-check
|
run: npm run format-check
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
# Test end-to-end by uploading two artifacts and then downloading them
|
# Test end-to-end by uploading two artifacts and then downloading them
|
||||||
- name: Create artifact files
|
- name: Create artifact files
|
||||||
run: |
|
run: |
|
||||||
mkdir -p path/to/dir-1
|
mkdir -p path/to/dir-1
|
||||||
mkdir -p path/to/dir-2
|
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 "Lorem ipsum dolor sit amet" > path/to/dir-1/file1.txt
|
||||||
echo "Hello world from file #2" > path/to/dir-2/file2.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
|
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-[23]/*
|
||||||
!path/to/dir-3/*.txt
|
!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
|
# Download Artifact #1 and verify the correctness of the content
|
||||||
- name: 'Download artifact #1'
|
- name: 'Download artifact #1'
|
||||||
uses: actions/download-artifact@v1
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: 'Artifact-A'
|
name: 'Artifact-A'
|
||||||
path: some/new/path
|
path: some/new/path
|
||||||
@ -109,7 +108,7 @@ jobs:
|
|||||||
|
|
||||||
# Download Artifact #2 and verify the correctness of the content
|
# Download Artifact #2 and verify the correctness of the content
|
||||||
- name: 'Download artifact #2'
|
- name: 'Download artifact #2'
|
||||||
uses: actions/download-artifact@v1
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: 'artifact'
|
name: 'artifact'
|
||||||
path: some/other/path
|
path: some/other/path
|
||||||
@ -127,10 +126,10 @@ jobs:
|
|||||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||||
}
|
}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
# Download Artifact #3 and verify the correctness of the content
|
# Download Artifact #3 and verify the correctness of the content
|
||||||
- name: 'Download artifact #3'
|
- name: 'Download artifact #3'
|
||||||
uses: actions/download-artifact@v1
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: 'GZip-Artifact'
|
name: 'GZip-Artifact'
|
||||||
path: gzip/artifact/path
|
path: gzip/artifact/path
|
||||||
@ -150,7 +149,7 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: 'Download artifact #4'
|
- name: 'Download artifact #4'
|
||||||
uses: actions/download-artifact@v1
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: 'Multi-Path-Artifact'
|
name: 'Multi-Path-Artifact'
|
||||||
path: multi/artifact
|
path: multi/artifact
|
||||||
|
2
.licenses/npm/@actions/artifact.dep.yml
generated
2
.licenses/npm/@actions/artifact.dep.yml
generated
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/artifact"
|
name: "@actions/artifact"
|
||||||
version: 1.0.0
|
version: 1.1.1
|
||||||
type: npm
|
type: npm
|
||||||
summary:
|
summary:
|
||||||
homepage:
|
homepage:
|
||||||
|
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.2.6
|
version: 1.10.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions core lib
|
summary: Actions core lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
2
.licenses/npm/@actions/glob.dep.yml
generated
2
.licenses/npm/@actions/glob.dep.yml
generated
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/glob"
|
name: "@actions/glob"
|
||||||
version: 0.1.0
|
version: 0.3.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions glob lib
|
summary: Actions glob lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/master/packages/glob
|
homepage: https://github.com/actions/toolkit/tree/master/packages/glob
|
||||||
|
2
.licenses/npm/@actions/io.dep.yml
generated
2
.licenses/npm/@actions/io.dep.yml
generated
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/io"
|
name: "@actions/io"
|
||||||
version: 1.0.2
|
version: 1.1.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions io lib
|
summary: Actions io lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/master/packages/io
|
homepage: https://github.com/actions/toolkit/tree/master/packages/io
|
||||||
|
161
README.md
161
README.md
@ -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.
|
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
|
# What's new
|
||||||
|
|
||||||
- Easier upload
|
🚧 Under construction 🚧
|
||||||
- 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
|
|
||||||
|
|
||||||
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
|
# Usage
|
||||||
|
|
||||||
@ -28,13 +22,13 @@ See [action.yml](action.yml)
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: mkdir -p path/to/artifact
|
- run: mkdir -p path/to/artifact
|
||||||
|
|
||||||
- run: echo hello > path/to/artifact/world.txt
|
- run: echo hello > path/to/artifact/world.txt
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: path/to/artifact/world.txt
|
path: path/to/artifact/world.txt
|
||||||
@ -43,7 +37,7 @@ steps:
|
|||||||
### Upload an Entire Directory
|
### Upload an Entire Directory
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: path/to/artifact/ # or path/to/artifact
|
path: path/to/artifact/ # or path/to/artifact
|
||||||
@ -52,7 +46,7 @@ steps:
|
|||||||
### Upload using a Wildcard Pattern
|
### Upload using a Wildcard Pattern
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: path/**/[abc]rtifac?/*
|
path: path/**/[abc]rtifac?/*
|
||||||
@ -61,7 +55,7 @@ steps:
|
|||||||
### Upload using Multiple Paths and Exclusions
|
### Upload using Multiple Paths and Exclusions
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: |
|
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:
|
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
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: path/to/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):
|
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
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
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
|
You can upload an artifact without specifying a name
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
path: path/to/artifact/world.txt
|
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
|
### 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
|
```yaml
|
||||||
- run: echo hi > world.txt
|
- run: echo hi > world.txt
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
path: world.txt
|
path: world.txt
|
||||||
|
|
||||||
- run: echo howdy > extra-file.txt
|
- run: echo howdy > extra-file.txt
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
path: extra-file.txt
|
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:
|
Artifact names must be unique since each created artifact is idempotent so multiple jobs cannot modify the same artifact.
|
||||||
|
|
||||||
```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 }}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Environment Variables and Tilde Expansion
|
### 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: |
|
- run: |
|
||||||
mkdir -p ~/new/artifact
|
mkdir -p ~/new/artifact
|
||||||
echo hello > ~/new/artifact/world.txt
|
echo hello > ~/new/artifact/world.txt
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: Artifacts-V3
|
name: Artifacts-V4-beta
|
||||||
path: ~/new/**/*
|
path: ~/new/**/*
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -199,7 +163,7 @@ Environment variables along with context expressions can also be used for input.
|
|||||||
- run: |
|
- run: |
|
||||||
mkdir -p ${{ github.workspace }}/artifact
|
mkdir -p ${{ github.workspace }}/artifact
|
||||||
echo hello > ${{ github.workspace }}/artifact/world.txt
|
echo hello > ${{ github.workspace }}/artifact/world.txt
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: ${{ env.name }}-name
|
name: ${{ env.name }}-name
|
||||||
path: ${{ github.workspace }}/artifact/**/*
|
path: ${{ github.workspace }}/artifact/**/*
|
||||||
@ -213,7 +177,7 @@ For environment variables created in other steps, make sure to use the `env` exp
|
|||||||
mkdir testing
|
mkdir testing
|
||||||
echo "This is a file to upload" > testing/file.txt
|
echo "This is a file to upload" > testing/file.txt
|
||||||
echo "artifactPath=testing/file.txt" >> $GITHUB_ENV
|
echo "artifactPath=testing/file.txt" >> $GITHUB_ENV
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: artifact
|
name: artifact
|
||||||
path: ${{ env.artifactPath }} # this will resolve to testing/file.txt at runtime
|
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
|
run: echo "I won't live long" > my_file.txt
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4-beta
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: my_file.txt
|
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).
|
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?
|
## 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:
|
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.
|
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.
|
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.
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
## Additional Documentation
|
## Additional Documentation
|
||||||
|
|
||||||
|
22
action.yml
22
action.yml
@ -1,7 +1,7 @@
|
|||||||
name: 'Upload a Build Artifact'
|
name: 'Upload a Build Artifact'
|
||||||
description: 'Upload a build artifact that can be used by subsequent workflow steps'
|
description: 'Upload a build artifact that can be used by subsequent workflow steps'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
name:
|
name:
|
||||||
description: 'Artifact name'
|
description: 'Artifact name'
|
||||||
default: 'artifact'
|
default: 'artifact'
|
||||||
@ -23,6 +23,24 @@ inputs:
|
|||||||
|
|
||||||
Minimum 1 day.
|
Minimum 1 day.
|
||||||
Maximum 90 days unless changed from the repository settings page.
|
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:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
124263
dist/index.js
vendored
124263
dist/index.js
vendored
File diff suppressed because one or more lines are too long
22493
package-lock.json
generated
22493
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -5,7 +5,7 @@
|
|||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"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\"",
|
"check-all": "concurrently \"npm:format-check\" \"npm:lint\" \"npm:test\" \"npm:build\"",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
@ -29,25 +29,25 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/upload-artifact#readme",
|
"homepage": "https://github.com/actions/upload-artifact#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.0.0",
|
"@actions/artifact": "^2.0.0",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/glob": "^0.1.0",
|
"@actions/glob": "^0.3.0",
|
||||||
"@actions/io": "^1.0.2"
|
"@actions/io": "^1.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.2.1",
|
"@types/jest": "^29.2.5",
|
||||||
"@types/node": "^13.11.1",
|
"@types/node": "^18.11.18",
|
||||||
"@typescript-eslint/parser": "^2.27.0",
|
"@typescript-eslint/parser": "^5.48.0",
|
||||||
"@zeit/ncc": "^0.22.1",
|
"@vercel/ncc": "^0.36.0",
|
||||||
"concurrently": "^5.1.0",
|
"concurrently": "^7.6.0",
|
||||||
"eslint": "^7.4.0",
|
"eslint": "^8.31.0",
|
||||||
"eslint-plugin-github": "^4.1.1",
|
"eslint-plugin-github": "^4.6.0",
|
||||||
"eslint-plugin-jest": "^23.8.2",
|
"eslint-plugin-jest": "^27.2.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^8.0.3",
|
||||||
"jest": "^27.2.5",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^27.2.5",
|
"jest-circus": "^29.3.1",
|
||||||
"prettier": "^2.0.4",
|
"prettier": "^2.8.1",
|
||||||
"ts-jest": "^27.0.6",
|
"ts-jest": "^29.0.3",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^4.9.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
/* eslint-disable no-unused-vars */
|
||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
Name = 'name',
|
Name = 'name',
|
||||||
Path = 'path',
|
Path = 'path',
|
||||||
IfNoFilesFound = 'if-no-files-found',
|
IfNoFilesFound = 'if-no-files-found',
|
||||||
RetentionDays = 'retention-days'
|
RetentionDays = 'retention-days',
|
||||||
|
CompressionLevel = 'compression-level'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NoFileOptions {
|
export enum NoFileOptions {
|
||||||
|
@ -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
|
return inputs
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '../node_modules/@actions/core/'
|
||||||
import {create, UploadOptions} from '@actions/artifact'
|
import artifact, {
|
||||||
|
UploadArtifactOptions
|
||||||
|
} from '../node_modules/@actions/artifact/lib/artifact'
|
||||||
import {findFilesToUpload} from './search'
|
import {findFilesToUpload} from './search'
|
||||||
import {getInputs} from './input-helper'
|
import {getInputs} from './input-helper'
|
||||||
import {NoFileOptions} from './constants'
|
import {NoFileOptions} from './constants'
|
||||||
@ -37,39 +39,29 @@ async function run(): Promise<void> {
|
|||||||
)
|
)
|
||||||
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
||||||
|
|
||||||
if (searchResult.filesToUpload.length > 10000) {
|
const options: UploadArtifactOptions = {}
|
||||||
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
|
|
||||||
}
|
|
||||||
if (inputs.retentionDays) {
|
if (inputs.retentionDays) {
|
||||||
options.retentionDays = 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,
|
inputs.artifactName,
|
||||||
searchResult.filesToUpload,
|
searchResult.filesToUpload,
|
||||||
searchResult.rootDirectory,
|
searchResult.rootDirectory,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
|
|
||||||
if (uploadResponse.failedItems.length > 0) {
|
core.info(
|
||||||
core.setFailed(
|
`Artifact ${inputs.artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
|
||||||
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
|
)
|
||||||
)
|
core.setOutput('artifact-id', uploadResponse.id)
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
core.setFailed(err.message)
|
core.setFailed((error as Error).message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,4 +20,9 @@ export interface UploadInputs {
|
|||||||
* Duration after which artifact will expire in days
|
* Duration after which artifact will expire in days
|
||||||
*/
|
*/
|
||||||
retentionDays: number
|
retentionDays: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The level of compression for Zlib to be applied to the artifact archive.
|
||||||
|
*/
|
||||||
|
compressionLevel?: number
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user