Temporary fork until v4 supports GHES.
Find a file
2023-12-13 16:06:43 -05:00
.devcontainer Update to latest actions/artifact NPM package (#195) 2023-01-04 17:30:33 -05:00
.github update test workflow to use different artifact names for matrix 2023-12-12 19:38:16 -05:00
.licenses/npm licensed cache 2023-12-13 16:06:43 -05:00
dist update docs and bump @actions/artifact 2023-12-12 19:21:23 -05:00
src consume latest @actions/toolkit 2023-12-06 19:43:53 -05:00
.eslintignore V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00
.eslintrc.json V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00
.gitattributes Ignore Generated Files in Git PR's 2020-08-26 11:21:58 -04:00
.gitignore V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00
.licensed.yml Manually Review licenses 2020-08-11 20:23:22 -04:00
.prettierignore V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00
.prettierrc.json V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00
action.yml update docs and bump @actions/artifact 2023-12-12 19:21:23 -05:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2020-07-13 12:49:43 +02:00
CONTRIBUTING.md Merge pull request #56 from thboop/main 2020-09-23 17:18:58 -04:00
LICENSE Create LICENSE 2019-07-23 15:29:14 -04:00
package-lock.json update docs and bump @actions/artifact 2023-12-12 19:21:23 -05:00
package.json update docs and bump @actions/artifact 2023-12-12 19:21:23 -05:00
README.md Update README.md 2023-12-13 12:48:35 -05:00
tsconfig.json V2 Download Artifact (#27) 2020-04-28 15:45:21 +02:00

@actions/download-artifact

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

See also upload-artifact.

v4 - What's new

Important

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

Improvements

  1. Downloads are significantly faster, upwards of 90% improvement in worst case scenarios.
  2. Artifacts can be downloaded from other workflow runs and repositories when supplied with a PAT.

Breaking Changes

  1. On self hosted runners, additional firewall rules may be required.
  2. Downloading artifacts that were created from action/upload-artifact@v3 and below are not supported.

Usage

Inputs

- uses: actions/download-artifact@v4
  with:
    # Name of the artifact to download.
    # Optional. If unspecified, all artifacts for the run are downloaded.
    name:

    # Destination path. Supports basic tilde expansion.
    # Optional. Defaults is $GITHUB_WORKSPACE
    path:

    # The GitHub token used to authenticate with the GitHub API.
    # This is required when downloading artifacts from a different repository or from a different workflow run.
    # Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
    github-token:

    # The repository owner and the repository name joined together by "/".
    # If github-token is specified, this is the repository that artifacts will be downloaded from.
    # Optional. Default is ${{ github.repository }}
    repository:

    # The id of the workflow run where the desired download artifact was uploaded from.
    # If github-token is specified, this is the run that artifacts will be downloaded from.
    # Optional. Default is ${{ github.repository }}
    run-id:

Outputs

Name Description Example
download-path Absolute path where the artifact(s) were downloaded /tmp/my/download/path

Examples

Download Single Artifact

Download to current working directory ($GITHUB_WORKSPACE):

steps:
- uses: actions/download-artifact@v4
  with:
    name: my-artifact
- name: Display structure of downloaded files
  run: ls -R

Download to a specific directory (also supports ~ expansion):

steps:
- uses: actions/download-artifact@v4
  with:
    name: my-artifact
    path: your/destination/dir
- name: Display structure of downloaded files
  run: ls -R your/destination/dir

Download All Artifacts

If the name input parameter is not provided, all artifacts will be downloaded. To differentiate between downloaded artifacts, a directory denoted by the artifacts name will be created for each individual artifact.

Example, if there are two artifacts Artifact-A and Artifact-B, and the directory is etc/usr/artifacts/, the directory structure will look like this:

etc/usr/artifacts/
    Artifact-A/
        ... contents of Artifact-A
    Artifact-B/
        ... contents of Artifact-B

Download all artifacts to the current working directory:

steps:
- uses: actions/download-artifact@v4
- name: Display structure of downloaded files
  run: ls -R

Download all artifacts to a specific directory:

steps:
- uses: actions/download-artifact@v4
  with:
    path: path/to/artifacts
- name: Display structure of downloaded files
  run: ls -R path/to/artifacts

Download Artifacts from other Workflow Runs or Repositories

It may be useful to download Artifacts from other workflow runs, or even other repositories. By default, the permissions are scoped so they can only download Artifacts within the current workflow run. To elevate permissions for this scenario, you can specify a github-token along with other repository and run identifiers:

steps:
- uses: actions/download-artifact@v4
  with:
    name: my-other-artifact
    github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo
    repository: actions/toolkit
    run-id: 1234

Limitations

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