Code Monkey home page Code Monkey logo

upload-artifact's Introduction

@actions/upload-artifact

Warning

actions/upload-artifact@v3 is scheduled for deprecation on November 30, 2024. Learn more. Similarly, v1/v2 are scheduled for deprecation on June 30, 2024. Please update your workflow to use v4 of the artifact actions. This deprecation will not impact any existing versions of GitHub Enterprise Server being used by customers.

Upload Actions Artifacts from your Workflow Runs. Internally powered by @actions/artifact package.

See also download-artifact.

v4 - What's new

Important

upload-artifact@v4+ is not currently supported on GHES yet. If you are on GHES, you must use v3.

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.

For more information, see the @actions/artifact documentation.

There is also a new sub-action, actions/upload-artifact/merge. For more info, check out that action's README.

Improvements

  1. Uploads are significantly faster, upwards of 90% improvement in worst case scenarios.
  2. Once uploaded, an Artifact ID is returned and Artifacts are immediately available in the UI and REST API. Previously, you would have to wait for the run to be completed before an ID was available or any APIs could be utilized.
  3. The contents of an Artifact are uploaded together into an immutable archive. They cannot be altered by subsequent jobs unless the Artifacts are deleted and recreated (where they will have a new ID). Both of these factors help reduce the possibility of accidentally corrupting Artifact files.
  4. The compression level of an Artifact can be manually tweaked for speed or size reduction.

Breaking Changes

  1. On self hosted runners, additional firewall rules may be required.

  2. Uploading to the same named Artifact multiple times.

    Due to how Artifacts are created in this new version, it is no longer possible to upload to the same named Artifact multiple times. You must either split the uploads into multiple Artifacts with different names, or only upload once. Otherwise you will encounter an error.

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

For assistance with breaking changes, see MIGRATION.md.

Usage

Inputs

- uses: actions/upload-artifact@v4
  with:
    # Name of the artifact to upload.
    # Optional. Default is 'artifact'
    name:

    # A file, directory or wildcard pattern that describes what to upload
    # Required.
    path:

    # The desired behavior if no files are found using the provided path.
    # Available Options:
    #   warn: Output a warning but do not fail the action
    #   error: Fail the action with an error message
    #   ignore: Do not output any warnings or errors, the action does not fail
    # Optional. Default is 'warn'
    if-no-files-found:

    # Duration after which artifact will expire in days. 0 means using default retention.
    # Minimum 1 day.
    # Maximum 90 days unless changed from the repository settings page.
    # Optional. Defaults to repository settings.
    retention-days:

    # The level of compression for Zlib to be applied to the artifact archive.
    # The value can range from 0 to 9.
    # For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
    # Optional. Default is '6'
    compression-level:

    # If true, an artifact with a matching name will be deleted before a new one is uploaded.
    # If false, the action will fail if an artifact for the given name already exists.
    # Does not fail if the artifact does not exist.
    # Optional. Default is 'false'
    overwrite:

Outputs

Name Description Example
artifact-id GitHub ID of an Artifact, can be used by the REST API 1234
artifact-url URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234

Examples

Upload an Individual File

steps:
- run: mkdir -p path/to/artifact
- run: echo hello > path/to/artifact/world.txt
- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: path/to/artifact/world.txt

Upload an Entire Directory

- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: path/to/artifact/ # or path/to/artifact

Upload using a Wildcard Pattern

- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: path/**/[abc]rtifac?/*

Upload using Multiple Paths and Exclusions

- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: |
      path/output/bin/
      path/output/test-results
      !path/**/*.tmp

For supported wildcards along with behavior and documentation, see @actions/glob which is used internally to search for files.

If a wildcard pattern is used, the path hierarchy will be preserved after the first wildcard pattern:

path/to/*/directory/foo?.txt =>
    ∟ path/to/some/directory/foo1.txt
    ∟ path/to/some/directory/foo2.txt
    ∟ path/to/other/directory/foo1.txt

would be flattened and uploaded as =>
    ∟ some/directory/foo1.txt
    ∟ some/directory/foo2.txt
    ∟ other/directory/foo1.txt

If multiple paths are provided as input, the least common ancestor of all the search paths will be used as the root directory of the artifact. Exclude paths do not affect the directory structure.

Relative and absolute file paths are both allowed. Relative paths are rooted against the current working directory. Paths that begin with a wildcard character should be quoted to avoid being interpreted as YAML aliases.

Altering compressions level (speed v. size)

If you are uploading large or easily compressable data to your artifact, you may benefit from tweaking the compression level. By default, the compression level is 6, the same as GNU Gzip.

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.

For instance, if you are uploading random binary data, you can save a lot of time by opting out of compression completely, since it won't benefit:

- name: Make a 1GB random binary file
  run: |
    dd if=/dev/urandom of=my-1gb-file bs=1M count=1000
- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: my-1gb-file
    compression-level: 0 # no compression

But, if you are uploading data that is easily compressed (like plaintext, code, etc) you can save space and cost by having a higher compression level. But this will be heavier on the CPU therefore slower to upload:

- name: Make a file with a lot of repeated text
  run: |
    for i in {1..100000}; do echo -n 'foobar' >> foobar.txt; done
- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: foobar.txt
    compression-level: 9 # maximum compression

Customization 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:

- uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: path/to/artifact/
    if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

(Not) Uploading to the same artifact

Unlike earlier versions of upload-artifact, uploading to the same artifact via multiple jobs is not supported with v4.

- run: echo hi > world.txt
- uses: actions/upload-artifact@v4
  with:
    # implicitly named as 'artifact'
    path: world.txt

- run: echo howdy > extra-file.txt
- uses: actions/upload-artifact@v4
  with:
    # also implicitly named as 'artifact', will fail here!
    path: extra-file.txt

Artifact names must be unique since each created artifact is idempotent so multiple jobs cannot modify the same artifact.

In matrix scenarios, be careful to not accidentally upload to the same artifact, or else you will encounter conflict errors. It would be best to name the artifact with a prefix or suffix from the matrix:

jobs:
  upload:
    name: Generate Build Artifacts

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        version: [a, b, c]

    runs-on: ${{ matrix.os }}

    steps:
    - name: Build
      run: ./some-script --version=${{ matrix.version }} > my-binary
    - name: Upload
      uses: actions/upload-artifact@v4
      with:
        name: binary-${{ matrix.os }}-${{ matrix.version }}
        path: my-binary

This will result in artifacts like: binary-ubuntu-latest-a, binary-windows-latest-b, and so on.

Previously the behavior allowed for the artifact names to be the same which resulted in unexpected mutations and accidental corruption. Artifacts created by upload-artifact@v4 are immutable.

Environment Variables and Tilde Expansion

You can use ~ in the path input as a substitute for $HOME. Basic tilde expansion is supported:

  - run: |
      mkdir -p ~/new/artifact
      echo hello > ~/new/artifact/world.txt
  - uses: actions/upload-artifact@v4
    with:
      name: my-artifacts
      path: ~/new/**/*

Environment variables along with context expressions can also be used for input. For documentation see context and expression syntax:

    env:
      name: my-artifact
    steps:
    - run: |
        mkdir -p ${{ github.workspace }}/artifact
        echo hello > ${{ github.workspace }}/artifact/world.txt
    - uses: actions/upload-artifact@v4
      with:
        name: ${{ env.name }}-name
        path: ${{ github.workspace }}/artifact/**/*

For environment variables created in other steps, make sure to use the env expression syntax

    steps:
    - run: |
        mkdir testing
        echo "This is a file to upload" > testing/file.txt
        echo "artifactPath=testing/file.txt" >> $GITHUB_ENV
    - uses: actions/upload-artifact@v4
      with:
        name: artifact
        path: ${{ env.artifactPath }} # this will resolve to testing/file.txt at runtime

Retention Period

Artifacts are retained for 90 days by default. You can specify a shorter retention period using the retention-days input:

  - name: Create a file
    run: echo "I won't live long" > my_file.txt

  - name: Upload Artifact
    uses: actions/upload-artifact@v4
    with:
      name: my-artifact
      path: my_file.txt
      retention-days: 5

The retention period must be between 1 and 90 inclusive. For more information see artifact and log retention policies.

Using 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.

Example output between steps

    - uses: actions/upload-artifact@v4
      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

jobs:
  job1:
    runs-on: ubuntu-latest
    outputs:
      output1: ${{ steps.artifact-upload-step.outputs.artifact-id }}
    steps:
      - uses: actions/upload-artifact@v4
        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"

Overwriting an Artifact

Although it's not possible to mutate an Artifact, can completely overwrite one. But do note that this will give the Artifact a new ID, the previous one will no longer exist:

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - name: Create a file
        run: echo "hello world" > my-file.txt
      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: my-artifact # NOTE: same artifact name
          path: my-file.txt
  upload-again:
    needs: upload
    runs-on: ubuntu-latest
    steps:
      - name: Create a different file
        run: echo "goodbye world" > my-file.txt
      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: my-artifact # NOTE: same artifact name
          path: my-file.txt
          overwrite: true

Limitations

Number of Artifacts

Within an individual job, there is a limit of 500 artifacts that can be created for that job.

You may also be limited by Artifacts if you have exceeded your shared storage quota. Storage is calculated every 6-12 hours. See the documentation for more info.

Zip archives

When an Artifact is uploaded, all the files are assembled into an immutable Zip archive. There is currently no way to download artifacts in a format other than a Zip or to download individual artifact contents.

Permission Loss

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.

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.

- name: 'Tar files'
  run: tar -cvf my_files.tar /path/to/my/directory

- name: 'Upload Artifact'
  uses: actions/upload-artifact@v4
  with:
    name: my-artifact
    path: my_files.tar

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:

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 size of the zip that upload-artifact creates during upload.

upload-artifact's People

Contributors

andrewakim avatar bethanyj28 avatar brcrista avatar brian-keebo avatar bryanmacfarlane avatar chrispat avatar dependabot[bot] avatar eggyhead avatar ethomson avatar gimenete avatar gmelikov avatar hugovk avatar jamesmgreene avatar jasongross avatar joshmgross avatar jozefizso avatar jtamsut avatar jweissig avatar konradpabjan avatar limonte avatar ljmf00 avatar markmssd avatar nombrekeff avatar nschonni avatar robherley avatar stonecypher avatar thboop avatar tingluohuang avatar vmjoseph avatar yacaovsnc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upload-artifact's Issues

Support artifact URL output

Hi,

This suggestion has been discussed here in the GitHub community forum.

In a Github Actions job, after an upload-artifact step, I would like to get the URL of the published artifact in a subsequent step.

The idea is a job using the following steps:

  • Build a binary.
  • Upload the binary as artifact.
  • Trigger a REST API in some Web server, passing the URL of the artifact in a POST parameter, so that the remote server can download the artifact.

How would you get the URL of the artifact in a subsequent step?

I know that there is an Actions API currently in development. But, here, the question is about passing information from the upload-artifact step to the next step.

It could be something like this:

    - name: Upload build
      uses: actions/upload-artifact@master
      with:
        name: installer
        path: installer.exe
        env-url: FOOBAR
    - name: Use URL for something
      run: echo "${{ env.FOOBAR }}"

The last command would display something like:

https://github.com/user/repo/suites/123456/artifacts/789123

Upload fails, appears to be looking at the wrong path. (Windows Only)

Hi,

Thank you for this plugin. Everything was working correctly during the beta, however, uploading on windows appears to fail due to a project path being duplicated. I suspect the path should be d:\a\PDO\build\coverage with only one PDO folder.

Run actions/upload-artifact@master
  with:
    name: coverage-report
    path: build/coverage
##[error]Path does not exist d:\a\PDO\PDO\build\coverage
##[error]Exit code 1 returned from process: file name 'c:\runners\2.162.0\bin\Runner.PluginHost.exe', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

Allow disabling the archiving stage.

Sometimes it would be useful to publish artifact without archiving it, e.g. when artifact is a single file, or I created the archive by myself (for example, I want to archive to .tar.gz on Ubuntu/macOS jobs and to .zip on Windows).

Files with colons in the name are missing in the artifact.

The upload is successful but files with colons in the name are missing in the artifact.

https://github.com/nickelc/azure-test/runs/311758340#step:5:8

Run actions/upload-artifact@v1
  with:
    name: docs
    path: docs
Uploading artifact 'docs' from '/home/runner/work/azure-test/azure-test/docs' for run #80
Uploading 125 files
Total file: 125 ---- Processed file: 2 (1%)
Fail to upload '/home/runner/work/azure-test/azure-test/docs/modio::Filehash.md' due to 'TF10123: The path 'docs/modio::Filehash.md' contains the character ':'. Remove the ':' and try again.'.
GitHub.Services.Common.VssServiceException: TF10123: The path 'docs/modio::Filehash.md' contains the character ':'. Remove the ':' and try again.

The files are coming from a cloned wiki repository of a GitHub repository.
OG GitHub is not compatible with MS GitHub 😁

Artifact download URL only work for registered users (404 for guests)

We used to copy the URL from https://github.com/actions/upload-artifact#where-does-the-upload-go to our website for nightly builds (which have short retention and frequent updates, and don't warrant a GitHub Releases push).

We intended to replace this with programmable download URLs that have been discussed in many issues on the repositories (either a latest/release.zip or a third party service which asks the Actions API for the latest URL and redirects the user).

This stopped working very recently.


Until recently, the actions tab was only viewable for logged in users (confusing 404 HTTP error for guests), but the artifact download URLs were still public (working for logged in users and also guests).

Likewise, when the Actions API was released, API requests worked without any authentication. One could simply query the API for an artifact download URL and redirect the guests to it. - All of that worked without GitHub account and could have worked from JavaScript or a small lightweight webservice which redirects the end-user to the latest artifact download through HTTP redirects (I wrote https://github.com/JayFoxRox/GitHub-artifact-URL for this purpose).

However, within the last days these artifact download URLs were suddenly made private - they only work for registered GitHub users now. Everyone clicking the download button on our website (who isn't logged into GitHub) gets a confusing 404 error for direct artifact download URLs now.

Even my tool to redirect users doesn't work anymore because the Actions API also requires the API client to be authenticated now (also getting a confusing "not found" error otherwise). See JayFoxRox/GitHub-artifact-URL#4 ; even if I implemented authentication now, the download URL (we redirect to) would likely not work for guest users (such as end-users of our software, who don't have a GitHub account).

It really starts to feel like we are working against how GitHub Actions is intended to work (now, and in the future - none of which seems to be documented very well). It is clearly different from any other CI I have ever worked with; because Travis and AppVeyor had public artifact URLs with simple URLs, which could be easily linked from our website (Compare AppVeyor).

The GitHub documentation for artifacts says

Artifacts allow you to share data between jobs in a workflow and store data once that workflow has completed.

The first part is obvious; but the second part is really vague. Who shall access this stored data? Why? - My thinking has been (from experience with other CI systems): to share temporary builds, with users for early-testing ("continuous integration"), without pushing a release.

  • Please make GitHub Actions artifact URLs work for guest users. If this is a non-goal, it should be documented.
  • Please document how things are supposed to work for real world applications (How to best handle nightly builds - currently neither GitHub Releases or GitHub Actions artifacts seem suitable).

Upload-artifact not working for steps running in containers

Hello,

I have a yml using a container to run steps:

    runs-on: ubuntu-18.04
    container:
      image: my-container-on-docker-hub:latest
      volumes:
        - /github/home/.folder:/github/home/.folder
    steps:
    - name: ls
      run: ls -la $HOME
    - uses: actions/upload-artifact@master
      with:
        name: my-artifact
        path: /github/home/.folder

Inside the container if I ls -la /github/home I get:

total 16
drwxr-xr-x 4 1001  115 4096 Sep 12 23:47 .
drwxr-xr-x 4 root root 4096 Sep 12 23:47 ..
drwxr-xr-x 3 root root 4096 Sep 12 23:47 .folder
drwxr-xr-x 2 root root 4096 Sep 12 23:47 .ssh

However the upload-artifact step returns:

Run actions/upload-artifact@master
  with:
    name: my-artifact
    path: /github/home/.folder
##[error]Path does not exist /github/home/.folder
##[error]Exit code 1 returned from process: file name '/home/runner/runners/2.157.3/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

I suspect that upload-artifact runs outside of the container and that's why I tried using volumes to make the data accessible on both sides, but it didn't help.
Is this an issue with volumes or upload-artifact?

Thanks

Allow ommitting the path

It is now required to provide a path for every artifact you upload. I have a repository where the artifacts are ending up in the root of the git repository (it is a fairly small project). I would expect the default path to be the git repository and a possible override of the path being relative to it, but this might not be true, it is not documented that clearly. Anyway, if the artifacts to upload are in a default path, specifying the path is redundant.

Artifact zip uses chmod 0600, which some file managers dislike

$ zipinfo Slides.zip
Archive:  /Users/zw/Downloads/Slides.zip
Zip file size: 30757126 bytes, number of entries: 2
-rw----     2.0 fat        0 b- stor 19-Dec-01 06:14 Slides/
-rw----     2.0 fat 31608616 bl defN 19-Dec-01 06:14 Slides/Slides.pdf
2 files, 31608616 bytes uncompressed, 30756888 bytes compressed:  2.7%

Some extraction tools ignore the 0600 (f.ex., Archive Utility on the Mac), while others take it literally (funnily enough, f.ex., Safari's "Open 'safe' files after downloading") If it is kept, file managers may prevent access, which is annoying. For example, here's a directory at 0600:

Screen Shot 2019-12-01 at 1 41 08 AM

I've also reproduced the same problem when downloading the artifact on Ubuntu.

This is not related to the chmod at time of upload; for instance, I added a chmod -R 0777 to the output before uploading it, and it had no effect.

The zips should be created without capturing permissions, or at least with a permission of 0644 if it is being set somehow.

File permission problem with zip.

I have a file permission problem with zip.

Here's what I have in github actions log:

image

And unzipping it with unzip myflow.zip -d . on my Ubuntu 16.04 server would remove the x(execute permission) from file myflow:

-rw-rw-r-- 1 ubuntu ubuntu 4.4K Sep  7 15:45 myflow

while the umask -S result is:

u=rwx,g=rwx,o=rx

Seems the umask is not respected by unzip command which is quite annoying.

Name Restrictions

Currently facing this issue where I want the name of the PR in the name of the artifact, but

##[error]Artifact name is not valid: WeakAuras-Companion-PR-fix/discord-channel-Node10. It cannot contain '\', '/', "', ':', '<', '>', '|', '*', and '?'

any chance you guys can escape this?

Omitting the enclosing directory

This is sort of similar to #3, but perhaps has a slightly easier path.

Right now, the action only support uploading a folder. This is not ideal, but I'm able to work with it. However, when zipping up the content, it includes the enclosing directory itself, resulting in a structure like this when downloading the zip file (from the UI, or from the download action):

some-folder.zip
└── some-folder
    ├── nested-folder
    │   └── some-nested-file.txt
    ├── some-file.txt
    └── another-file.txt

This is unnecessary for my use case. Ideally, I would want to zip file to have this structure:

some-folder.zip
├── nested-folder
│   └── some-nested-file.txt
├── some-file.txt
└── another-file.txt

The difference being that the enclosing folder ("some-folder") is no longer included in the zip file.

In my use case, this is important. I'm using GH Actions to build a chrome/firefox extension. Their submission form accept a zip file with a known structure. If I can omit the enclosing folder, I can always get what I want by restructuring the content of the folder I'm passing to this action. With the current setup, there is no way to accomplish that since there will always be an extraneous folder at the root of the zip file, which is not allowed.

Instead, I'll have to create the zip file in the format I wanted, put it into a folder, pass it to this action, then later download the zip-file-containing-a-folder-containing-a-zip-file from the UI, then upload that to the submission form.

Of course, it would be even nicer if this action can take an arbitrary list of files, including glob patterns, etc. But even without any of that, if we can omit the enclosing folder at the root, it is sufficient to create arbitrary artifacts archive (but making an additional temporary folder and copying things around).

Support transient/temporary artifacts with a retention period of 0

Hello,

Some of my artifacts are transient. They transmit data between jobs but I don't want to keep them.

Ideally, I would like to use actions/upload-artifact like this:

- name: Upload artifact
  uses: actions/upload-artifact@v2
  with:
    name: myartifact
    path: mypath
    temporary: true

The temporary (or transient) flag would mark the artifact as transient and automatically delete it when the workflow is done.

Uploading a single file

Say I wish to upload a screenshot made from puppeteer, can it be possible to upload just the image generated rather than a zip file only containing that image.

Cannot extract zip file with Ubuntu 18.04 file manager UI

Ok, I'll admit this is a strange one... 😉

My build uses the upload-artifact action that creates a zip.
I am able to unzip that file with the macOS Finder and the Ubuntu 19.04 file manager UI.

However, if I try to extract the same zip file with the Ubuntu 18.04.2 LTS file manager (Nautilus) it fails:

extracting2

The message reads: "There was an error extracting "socket-connect-bpf.zip". "Error opening file "{file}": Not a directory"
If I unzip the same file with:

unzip socket-connect-bpf.zip

it works as well...

I could reproduce this behavior on a second Ubuntu 18.04.2 install.

I don't know if the upload-artifact action could zip the files differently?

How to specify the path

I have files in /home/runner/work/.../src/MyProject/bin/Release ... I tried copying this path but I get an error:

##[error]Value cannot be null. (Parameter 'name')
##[error]Exit code 1 returned from process: file name '/home/runner/runners/2.162.0/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

Don't use @master in your workflow

During the beta of GitHub Actions, a lot of documentation (including the README for this action) showed example YAML with master being referenced:

uses: actions/upload-artifact@master

We currently encourage users to not use master as a reference whenever an action is being used. Instead, one of the available tags should be used such as:

uses: actions/upload-artifact@v1

Tags are used alongside semantic versioning to provide a stable experience: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-actions#versioning-your-action

The master branch can abruptly change without notice during development which can cause workflows to unexpectedly fail. If you want to avoid unexpected changes or failures, you should use a tag when referring to a specific version of an action. Tags are added to stable versions that have undergone significant testing and should not change.

The v2 versions of download-artifact and upload-artifact are currently in development. Expect changes to start showing up in the v2-preview branch. These new changes will eventually be merged into master (we will communicate about this in the future) and that will have the potential to break your workflows if you are using @master so you will have to react by updating your YAML to use a tag.

Our telemetry indicates a significant amount of users are using @master. Good practice for all actions is to use a tag instead of referencing @master.

upload-artifact does not retain artifact permissions

The baseline behavior of the zip utilty on Linux and macOS is to retain permissions.

However, when the upload-artifact action zips a directory, it loses permissions, which subsequently breaks the artifacts for users and downstream tools.

Expected behavior: the permissions applied to assets in prior steps should be retained by the upload-artifact zipper, and should be present in the resulting asset zip file.

Is there any way to get the link to the uploaded artifact?

Is there any way to programmatically retrieve the link to download the artifact?

eg. https://github.com/SiliconJungles/app/suites/574454195/artifacts/5483355

When I used CircleCI, I would build an Android APK, retrieve the download link & download token, then post the link onto discord so other members of the team could directly download the APK file without having to open the CI webpage and without having to log in.

Is there any way to achieve this with GitHub Actions?

Support Retention Policies

Now that GitHub has a strict quota and charges on storage usage, the ability to remove artifacts is an essential feature. This is covered in #5, however, since Actions are automated, manual removal is too tedious.

I'd like to suggest supporting retention policies instead where after a period of time (specified in the job step), artifacts automatically clear themselves out to avoid wasting storage space.

For example, when sharing artifacts between jobs, they're only needed for an hour maximum, and for debugging tests they may not be needed for more than a day.

Here is a configuration example where expires is the retention policy given in seconds.

- uses: actions/upload-artifact@v1
  with:
    name: my-artifact-for-one-hour
    path: path/to/artifact
    expires: 3600
- uses: actions/upload-artifact@v1
  with:
    name: my-artifact-for-one-day
    path: path/to/another/artifact
    expires: 86400

Without this, the entire idea of "Shared Storage" in GitHub Actions is unusable for Teams and Individuals with fixed budgets as the costs will just keep growing.

#5 will still be needed to remove artifacts that don't have a retention policy.

support env in name

first of all thank you for this action ! it is very usefull !
secondly I have a feature request,

actions/upload-artifact

    - uses: actions/upload-artifact@v1
      with:
        name: all_reports
        path: all_reports

I would like to be able to change the name based on the GITHUB_REF env variables

I tried this but it wont work:

    - uses: actions/upload-artifact@v1
      with:
        name: all_reports_${GITHUB_REF}
        path: all_reports

I also have tried

       name: all_reports_${{ GITHUB_REF }}

no luck

Open source this action

It is surprising that this repo (the scripts and documentation in this project) is licensed under MIT, since there is little to no relevant content to be licensed. However, I'm concerned about this from a practical point of view. I believe that most of the currently open issues (specially #3) could be fixed by the community, should we have any code to look at. It'd be really useful if the glue logic that gathers the artifacts and names them was open sourced, along with some minimal docs about the backend API that this action is using.

`upload-artifact` double-zips a zip

When upload-artifact is provided an existing zip file via its path: argument:

        with:
          name: asset-package
          path: asset-package.zip

It double-zips the zip, resulting a zip within a zip.

"You're using it wrong, don't provide a zip file!", might be a counter-argument, however zips might be preferred because:

  • Some off-the-shelf workflows automatically produce a zipped result, therefore it would make sense to take it as-is.
  • Re-zipping needlessly burns CPU, always results in a larger file, wastes user time, confuses users, and adds complexity to down-stream automation.
  • Providing a zip can be faster than uploading a directory of files because it avoids the per-file latency multiplier that (possibly thousands of) individual transfers incur.

"We can't trust your zipfile; what if it's some other file in disguise!", could be another argument:

  • Ok.. but the asset zipper already trusts any file anyway; so security already isn't a concern. People could already be feeding the assert zipper viruses and trojans for all we know.
  • If this is a concern, a content/type check could be applied to confirm the file is a bonafide zip. If you still don't trust it, then the zip could be decompressed to /dev/null and confirmed good, as opposed to double-zipping the zip.

Yes, a work-around would be to unzip our resulting zip to a temporary directory, and then provide that to the asset uploader - however we're now wasting three rounds of zipping: initial zip, unzip, re-zip.

GitHub already gives developers full control over the content that they're uploading, so using a zipfile straight-away is just another means to provide the same content without a second layer of packaging.

Specify shorter artifact retention time

Hi,

This suggestion has been discussed here in the GitHub community forum. It can be considered as an extension of #45.

The current retention time for artifacts is 90 days. I suggest a more flexible artifact retention duration. I have setup nightly builds on my open source project. I certainly do not need those nightly builds to be retained for 90 days. Keeping the last 5 days (or so) is sufficient,

The current retention time of 90 days should be a default one and/or a maximum one. But a shorter period should be allowed, either in the settings of the repo or on an artifact basis, for instance something like this:

    - name: Upload build
      uses: actions/upload-artifact@master
      with:
        name: installer
        path: installer.exe
        retention-days: 5

File size of uploaded artifacts shows up uncompressed

Not sure if this is an appropriate place for this issue, but basically once you upload an artifact with this action, it will appear in the artifacts list. The problem is that it shows the file size uncompressed, despite being packed in an archive.

Artifacts exceeded limits

We just started getting Cannot upload artifacts. You may have exceeded your spending limit for storing artifacts with Actions or Packages.

We have an artifact that takes about 5 minutes to produce, which is fed into a job that spins up multiple containers than run in parallel. The artifacts are only needed to feed these boxes, and can be removed after.

After 1 day, we started getting the message I wrote above. I have deleted every artifact I could find manually. Then I ran this action here that says it purged all my artifacts: https://github.com/kolpav/purge-artifacts-action

Clicking through as many previous workflows as I could, I found no examples of existing artifacts.

I continue to the get above message, and all merging has stopped on our project.

I need to know how to manage my artifacts so this doesn't happen again, and get my pipeline back up asap.

Thanks!

Blob is incomplete errors

Only started recently that I started getting Fail to upload '/home/runner/work/WeakAuras-Companion/WeakAuras-Companion/build/WeakAuras Companion-1.2.3.AppImage' due to 'Blob is incomplete (missing block). Blob: b92268561adee911b5e92818784a82c1, Expected Offset: 0, Actual Offset: 8388608'. GitHub.Services.WebApi.VssServiceResponseException: Blob is incomplete (missing block). Blob: b92268561adee911b5e92818784a82c1, Expected Offset: 0, Actual Offset: 8388608 ---> System.InvalidOperationException: Blob is incomplete (missing block). Blob: b92268561adee911b5e92818784a82c1, Expected Offset: 0, Actual Offset: 8388608 errors on my project https://github.com/WeakAuras/WeakAuras-Companion/runs/232817440

Any ideas?

Feature request: wildcards

One of the really useful things about uploading artifacts is caching logs, coverage reports, et cetera. Those often have timestamps or UUIDs as names.

You can hack around it with a compression to a known name step, but, uploading and downloading artifacts by wildcard (or even just download-all) would be a huge benefit

List artifacts doesn't work during workflow run

I tried to retrieve the list of artifacts in a second job using GET /repos/:owner/:repo/actions/runs/:run_id/artifacts after uploading some artifacts by actions/upload-artifact@v1 in the first job, but the artifacts won't show up. The API call will always return { "total_count": 0, "artifacts": [ ] }.
I have the second job depends on the first job.

Is there a solution to this?

Size limits?

Are there size limits on artifacts? Are there quotas for total number of artifacts? Do these count towards my 100GB hard limit on the size of my repo? (And, if you know, a similar question about pushing docker images to Github package registry?)

I'm looking to port a buildkite build to Github Actions - at the moment it generates some largish artifacts when it archives node_modules (to save time doing npm ci from one parallel task to the next). I was thinking about pushing a dev docker image instead, but right now our image is an astonishing 1G, which seems like an excessively large thing to push to either artifacts or to a package registry on each build. :P

Way to fetch the latest version of some artifact

@JayFoxRox This issue was tracking a way to get a link to an uploaded artifact. If you want some way to fetch the latest artifact, please file a new issue.
#27 (comment)

Hey there! I am opening a new issue as requested by @joshmgross. It would be incredibly helpful to have some way to fetch the latest version of an artifact.

For example, in my use case, I am using LaTeX for my resume and GitHub Actions to compile and create the PDF. It would be incredibly helpful to have a URL that fetches the most recent version. As mentioned in that thread, there is a workaround by pushing it to a release, which I will be using in the meantime but this would be a much more elegant solution.

Thanks!

Where does the upload go?

Where does the upload go to? Is there any meta information returned on success/failure? Can we control where the artifact is uploaded?

Sorry silly questions but the readme is a little on the slim side :)

How do I get the run number?

I am creating my own actions as NodeJS/JavaScript and I am wondering how do I get the build run number, so I can use it to append/amend version numbers for artefacts.

Uploading artifact 'package-artifacts' from 'd:\a\Take-Out-The-Trash\Take-Out-The-Trash\output' for run #45

As this repo does not show the source for this as its dealt with the plugin publish
actions/toolkit#69

Can you give me a pointer on where we can use this information please
/cc @TingluoHuang

The SSL connection could not be established

I am using a self hosted runner, on a windows box, behind a corporate firewall, and the running is running as a service account. I am able to run action-checkout, but i get this error below when trying to upload an artifact.

Thoughts?

SSL issues in my case typically stem from the proxy server in some way, but I have tried everything I know of, not sure how to verify the upload-artifact is using my proxy or if its just me.

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
 ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
   at System.Net.FixedSizeReader.ReadPacketAsync(Stream transport, AsyncProtocolRequest request)
   at System.Net.Security.SslStream.ThrowIfExceptional()
   at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__65_1(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at GitHub.Services.Common.VssHttpRetryMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at GitHub.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
   at GitHub.Services.FileContainer.Client.FileContainerHttpClient.UploadFileAsync(Int64 containerId, String itemPath, Stream fileStream, Byte[] contentId, Int64 fileLength, Boolean isGzipped, Guid scopeIdentifier, CancellationToken cancellationToken, Int32 chunkSize, Int32 chunkRetryTimes, Boolean uploadFirstChunk, Object userState)
   at GitHub.Services.FileContainer.Client.FileContainerHttpClient.UploadFileAsync(Int64 containerId, String itemPath, Stream fileStream, Guid scopeIdentifier, CancellationToken cancellationToken, Int32 chunkSize, Boolean uploadFirstChunk, Object userState, Boolean compressStream)
   at GitHub.Runner.Plugins.Artifact.FileContainerServer.UploadAsync(RunnerActionPluginExecutionContext context, Int32 uploaderId, CancellationToken token)
File upload complete.
Uploaded '0' bytes from 'D:\actions-runner\_work\bdw-mart\bdw-mart\build\BDW.dacpac' to server
##[error]The SSL connection could not be established, see inner exception.
##[error]Exit code 1 returned from process: file name 'D:\actions-runner\bin\Runner.PluginHost.exe', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

Support $HOME in Path Argument

This is a feature request to support $HOME in the path.

I'm trying to use the upload-artifact action as a step in a CI build. Most of my other steps are saving and storing files based on paths relative to $HOME, so it makes sense to be able to do the same here.

The workaround currently is to hardcode the path.

So currently I do something like this:

- uses: actions/upload-artifact@v1
  with:
      name: artifacts.zip
      path: /home/runner/my_file

But would like to do this:

- uses: actions/upload-artifact@v1
  with:
      name: artifacts.zip
      path: ${HOME}/my_file

Display files in browser where appropriate.

It would be nice to open html files in the browser instead of having to download and up zip the file. CircleCi does this. This is useful for test results or lint results and other types of reports.

Upload from macOS fails with 503 error

Uploading from macOS github runner with v2-is-almost-here gives me:

Received http 503 during chunk upload, will retry at offset 0 after 10 seconds. Received http 503 during chunk upload, will retry at offset 0 after 10 seconds. ##[error]read ECONNRESET

Uploading multiple artifacts with the same name silently quashes each other

I had a matrix build doing this:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [pypy2, pypy3, 3.7]

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip setuptools setuptools_scm wheel
    - name: Create packages
      run: python setup.py sdist bdist_wheel
    - uses: actions/upload-artifact@master
      with:
        name: dist
        path: dist

i.e. building an artifact using each of 3 Python versions, and where the 3 versions were all creating the same file and uploading it as the same name.

Might be nice for this to error out saying an artifact with the given name was already uploaded during this run of the workflow.

Exclude files/dirs either by name or regexp

It would be nice to have a way to exclude some files/directories from uploading. I would think about something like this:

steps:
- uses: actions/checkout@v1

- run: mkdir -p path/to/artifact

- run: echo hello > path/to/artifact/hello.txt
- run: echo hello > path/to/artifact/world.txt

- uses: actions/upload-artifact@v1
  with:
    name: my-artifact
    path: path/to/artifact
    exclude: .*rld.*

So only hello.txt will be archived/uploaded.

Might be ANT syntax is good.

support different archive types

It would be nice if you could specify the artifact archive type (e.g. 7z for Windows artifacts to get better compression, .tar.bz2 for Linux to preserve file metadata etc.).
Somewhat related to #3 (if you build the archive yourself) and #20 I guess.

[feature request] Allow conditional uploads

Hi folks ! I would like to request a feature.

Here is an example from an issue we are currently having, where we want to upload artifacts on a certain condition. We want to upload screenshots that are generated with cypress but only when the test run has failed (cypress manages the folder creation if it needs to create screenshots).

Currently, we have to add another step to verify that the folder exists and based on the output of that step, perform the upload. This makes the workflow a bit difficult to manage because on a run of that workflow where everything is successful, the step that checks the existence of the screenshot folder will be in a failure state and that can be confusing.

      - name: Check if screenshots folder exists
        if: always()
        run: test -d cypress/screenshots

      - name: When present, upload screenshots of test failures
        uses: actions/upload-artifact@v1
        if: success()
        with:
          name: cypress-screenshots
          path: cypress/screenshots

Could it be possible to have a implicit check, not as a default behaviour but with an option to skip the upload on a given condition ? Something like:

      - name: When present, upload screenshots of test failures
        uses: actions/upload-artifact@v1
        with:
          name: cypress-screenshots
          path: cypress/screenshots
          condition: folder-exists

folder-exists could map to an internal check that equals to test -d or any other equivalent. Different conditions could be implemented.

Maybe what I am asking it out of scope for this action but I thought I would take my chances.

Cheers !

Download artifacts of latest build

I'm working with two workflows in different platforms (A and B) and the workflow B needs an artifact of the workflow A. Also, I'm trying to avoid external services as S3 in order to make it simple.

Is there a way to get a link to the artifacts generated in the last build (latestbuild) or in the last passed build (lastsuccessfulbuild)?

Maybe something like this: https://github.com/{account}/{repo}/workflows/{workflowName}/builds/latest/artifacts/file.zip

Try out v2-preview

The v2-preview of upload-artifact is out and we need your help!

You can try it out by using actions/upload-artifact@v2-preview
Any associated code and documentation can be found here: https://github.com/actions/upload-artifact/tree/v2-preview

This issue is for general feedback and to report an bugs/issues during the preview

There is also a v2-preview for download-artifact 😀 see: actions/download-artifact#23

Warning: At any time during the preview, there may be unannounced changes that can cause things to break. It is recommended not to use the preview of this action in critical workflows


Historical Context around v2-preview and v1

The v1 versions of upload-artifact (and download-artifact ) are plugins that are executed by the runner. The code for v1 can be found here: https://github.com/actions/runner/tree/master/src/Runner.Plugins/Artifact

The v1 code is written in C# and is tightly coupled to the runner, it also uses special APIs that only the runner can use to interact with artifacts. If any changes or updates had to be made related to artifacts, they had to done on the runner and a new release had to roll out that would take a significant amount of time. With v2, there is no dependency on the runner so it will be much easier and faster to make changes and accept community contributions (right now it was pretty much impossible).

The v2-preview of upload-artifact has been rewritten from scratch using Typescript with a new set of APIs that allow it interact with artifacts (previously only the runner could do this). There is a new NPM package called @actions/artifact that contains the core functionality to interact with artifacts (which this action uses for the most part). This NPM package is hosted in the actions/toolkit repo so anyone can use this to interact with artifacts when developing actions. You can find the package here (lots of documentation and extra info):
https://www.npmjs.com/package/@actions/artifact
https://github.com/actions/toolkit/tree/master/packages/artifact

Further work

Since v2-preview is effectively a total rewrite from v1, There is a huge potential for bugs so it needs to be tested thoroughly before creating an actual v2 release. We need help testing the core functionality which includes:

  • Uploading an individual file
  • Uploading a directory
  • Uploading using wildcards

There will be no new features added as part of the v2-preview, we need to test the core functionality first and once a v2 release is out, then we can start chipping away at issues/features that we have been unable to address with v1🙂 For the moment, please don't submit PRs for any new features to the v2-preview branch.

Some initial observations from some internal testing show that v2-preview is slightly slower than v1 (around 10-15%). A large part of this discrepancy can be attributed to porting over from C# to Node. In C#, the runner would upload artifacts with Async Tasks and true multi-threading. With Node, the HTTP pipeline is not as efficient (we would love some help over in the toolkit repo for @actions/artifact if anyone is really good with TS, Aysnc/Await and HTTP pipelining to hopefully make this better)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.