Top Related Projects
Cache dependencies and build outputs in GitHub Actions
Action for checking out a repo
Run your GitHub Actions locally 🚀
Quick Overview
actions/download-artifact is a GitHub Action that allows you to download artifacts from your workflow runs. It's designed to work seamlessly with the actions/upload-artifact action, enabling easy sharing of data between jobs in a workflow or between different workflow runs.
Pros
- Easy integration with GitHub Actions workflows
- Supports downloading multiple artifacts in a single step
- Allows for flexible artifact naming and path customization
- Automatically handles retry logic for failed downloads
Cons
- Limited to GitHub Actions ecosystem
- May have size limitations for very large artifacts
- Requires careful management of artifact retention to avoid storage issues
- Potential security concerns if sensitive data is stored in artifacts
Code Examples
- Basic usage to download an artifact:
- uses: actions/download-artifact@v3
with:
name: my-artifact
- Download multiple artifacts to specific directories:
- uses: actions/download-artifact@v3
with:
name: artifact1
path: path/to/artifact1
- uses: actions/download-artifact@v3
with:
name: artifact2
path: path/to/artifact2
- Download all artifacts from the current workflow run:
- uses: actions/download-artifact@v3
Getting Started
To use actions/download-artifact in your GitHub Actions workflow:
- Add the following step to your workflow YAML file:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: my-artifact
path: path/to/download
- Replace
my-artifactwith the name of your artifact, and adjust thepathif needed. - Ensure that an artifact with the specified name has been uploaded in a previous job or workflow run using actions/upload-artifact.
- Run your workflow, and the artifact will be downloaded to the specified path.
Competitor Comparisons
Pros of upload-artifact
- Allows storing build artifacts for later use in the workflow or other jobs
- Supports uploading multiple files and directories in a single action
- Provides options for compression and retention period of artifacts
Cons of upload-artifact
- Limited storage capacity (default 500MB per repository)
- Artifacts are only available for a limited time (default 90 days)
- May increase workflow execution time for large artifacts
Code comparison
upload-artifact:
- uses: actions/upload-artifact@v3
with:
name: my-artifact
path: path/to/artifact/
retention-days: 5
download-artifact:
- uses: actions/download-artifact@v3
with:
name: my-artifact
path: path/to/download/
Key differences
- upload-artifact is used to store files, while download-artifact retrieves them
- upload-artifact requires specifying the source path, while download-artifact needs the destination path
- upload-artifact offers more configuration options (e.g., retention period, compression)
- download-artifact is typically used in subsequent jobs or workflows to access previously uploaded artifacts
Both actions work together to facilitate file sharing between jobs and workflows, enhancing the flexibility and efficiency of GitHub Actions pipelines.
Cache dependencies and build outputs in GitHub Actions
Pros of cache
- Faster retrieval of data across workflow runs
- Automatic cleanup of old caches to save storage space
- Can store and retrieve multiple files or directories in a single operation
Cons of cache
- Limited to 10GB per repository
- Cache keys must be manually managed to ensure uniqueness
- May not be suitable for frequently changing data
Code comparison
cache:
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
download-artifact:
- uses: actions/download-artifact@v3
with:
name: my-artifact
path: path/to/artifact
Key differences
- cache is designed for persisting data between workflow runs, while download-artifact is for retrieving artifacts from the same workflow run
- cache uses a key-based system for storing and retrieving data, whereas download-artifact uses a simpler name-based approach
- cache can store and retrieve multiple files or directories, while download-artifact is typically used for single artifacts
- download-artifact is more straightforward to use for simple artifact retrieval, while cache offers more flexibility and performance benefits for frequently accessed data
Action for checking out a repo
Pros of checkout
- Clones the entire repository, providing access to all files and history
- Automatically configures Git credentials for pushing changes
- Supports checking out specific branches, tags, or commit SHAs
Cons of checkout
- Can be slower for large repositories due to cloning the entire history
- Consumes more disk space as it downloads the full repository
- May include unnecessary files if only specific artifacts are needed
Code comparison
checkout:
- uses: actions/checkout@v3
with:
fetch-depth: 1
ref: main
download-artifact:
- uses: actions/download-artifact@v3
with:
name: my-artifact
path: path/to/artifact
Key differences
- checkout is used for accessing the repository's source code and Git history
- download-artifact is specifically for retrieving previously uploaded artifacts
- checkout allows for Git operations, while download-artifact is focused on file retrieval
- download-artifact is typically faster and more efficient when only specific files are needed
- checkout provides more flexibility for working with different branches and commits
Both actions serve different purposes and can be used together in workflows depending on the requirements of the job or step.
Run your GitHub Actions locally 🚀
Pros of act
- Allows local testing of GitHub Actions workflows without pushing to a repository
- Supports running workflows in Docker containers, simulating the GitHub Actions environment
- Provides flexibility to run specific jobs or entire workflows
Cons of act
- May not perfectly replicate the GitHub Actions environment, leading to potential discrepancies
- Requires Docker to be installed and running on the local machine
- Limited support for certain GitHub-specific features and secrets management
Code comparison
act:
# Run a specific job
act -j build
# Run an entire workflow
act push
download-artifact:
- uses: actions/download-artifact@v3
with:
name: my-artifact
path: path/to/artifact
Key differences
- Purpose: act is for local testing, while download-artifact is for retrieving artifacts in GitHub Actions workflows
- Functionality: act simulates entire workflows, while download-artifact focuses on a single task
- Usage context: act is used during development, while download-artifact is part of CI/CD pipelines
Use cases
- Use act for debugging and testing workflows locally before committing changes
- Use download-artifact to retrieve build artifacts or test results in subsequent workflow steps
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
@actions/download-artifact
Download Actions Artifacts from your Workflow Runs. Internally powered by the @actions/artifact package.
See also upload-artifact.
@actions/download-artifact
v7 - What's new
[!IMPORTANT] actions/download-artifact@v7 now runs on Node.js 24 (
runs.using: node24) and requires a minimum Actions Runner version of 2.327.1. If you are using self-hosted runners, ensure they are updated before upgrading.
Node.js 24
This release updates the runtime to Node.js 24. v6 had preliminary support for Node 24, however this action was by default still running on Node.js 20. Now this action by default will run on Node.js 24.
v5 - What's new
Previously, single artifact downloads behaved differently depending on how you specified the artifact:
- By name:
name: my-artifactâ extracted topath/(direct) - By ID:
artifact-ids: 12345â extracted topath/my-artifact/(nested)
Now both methods are consistent:
- By name:
name: my-artifactâ extracted topath/(unchanged) - By ID:
artifact-ids: 12345â extracted topath/(updated - now direct)
Note: This change also applies to patterns that only match a single artifact.
v4 - What's new
[!IMPORTANT] download-artifact@v4+ is not currently supported on GitHub Enterprise Server (GHES) yet. If you are on GHES, you must use v3 (Node 16) or v3-node20 (Node 20).
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
- Downloads are significantly faster, upwards of 90% improvement in worst case scenarios.
- Artifacts can be downloaded from other workflow runs and repositories when supplied with a PAT.
Breaking Changes
- On self hosted runners, additional firewall rules may be required.
- Downloading artifacts that were created from
action/upload-artifact@v3and below are not supported.
For assistance with breaking changes, see MIGRATION.md.
Note
Thank you for your interest in this GitHub repo, however, right now we are not taking contributions.
We continue to focus our resources on strategic areas that help our customers be successful while making developers' lives easier. While GitHub Actions remains a key part of this vision, we are allocating resources towards other areas of Actions and are not taking contributions to this repository at this time. The GitHub public roadmap is the best place to follow along for any updates on features weâre working on and what stage theyâre in.
We are taking the following steps to better direct requests related to GitHub Actions, including:
-
We will be directing questions and support requests to our Community Discussions area
-
High Priority bugs can be reported through Community Discussions or you can report these to our support team https://support.github.com/contact/bug-report.
-
Security Issues should be handled as per our security.md.
We will still provide security updates for this project and fix major breaking changes during this time.
You are welcome to still raise bugs in this repo.
Usage
Inputs
- uses: actions/download-artifact@v5
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name:
# IDs of the artifacts to download, comma-separated.
# Either inputs `artifact-ids` or `name` can be used, but not both.
# Optional.
artifact-ids:
# Destination path. Supports basic tilde expansion.
# Optional. Default is $GITHUB_WORKSPACE
path:
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Note: When downloading a single artifact (by name or ID), it will always be extracted directly to the specified path.
# Optional. Default is 'false'
merge-multiple:
# 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.run_id }}
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@v5
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@v5
with:
name: my-artifact
path: your/destination/dir
- name: Display structure of downloaded files
run: ls -R your/destination/dir
Download Artifacts by ID
The artifact-ids input allows downloading artifacts using their unique ID rather than name. This is particularly useful when working with immutable artifacts from actions/upload-artifact@v4 which assigns a unique ID to each artifact.
Download a single artifact by ID to the current working directory ($GITHUB_WORKSPACE):
steps:
- uses: actions/download-artifact@v5
with:
artifact-ids: 12345
- name: Display structure of downloaded files
run: ls -R
Download a single artifact by ID to a specific directory:
steps:
- uses: actions/download-artifact@v5
with:
artifact-ids: 12345
path: your/destination/dir
- name: Display structure of downloaded files
run: ls -R your/destination/dir
When downloading a single artifact by ID, the behavior is identical to downloading by name - the artifact contents are extracted directly to the specified path without creating a subdirectory.
Multiple artifacts can be downloaded by providing a comma-separated list of IDs:
steps:
- uses: actions/download-artifact@v5
with:
artifact-ids: 12345,67890
path: path/to/artifacts
- name: Display structure of downloaded files
run: ls -R path/to/artifacts
When downloading multiple artifacts by ID, each artifact will be extracted into its own subdirectory named after the artifact (similar to downloading multiple artifacts by name).
Download All Artifacts
If the name input parameter is not provided, all artifacts will be downloaded. To differentiate between downloaded artifacts, by default a directory denoted by the artifacts name will be created for each individual artifact. This behavior can be changed with the merge-multiple input parameter.
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@v5
- name: Display structure of downloaded files
run: ls -R
Download all artifacts to a specific directory:
steps:
- uses: actions/download-artifact@v5
with:
path: path/to/artifacts
- name: Display structure of downloaded files
run: ls -R path/to/artifacts
To download them to the same directory:
steps:
- uses: actions/download-artifact@v5
with:
path: path/to/artifacts
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R path/to/artifacts
Which will result in:
path/to/artifacts/
... contents of Artifact-A
... contents of Artifact-B
Download multiple (filtered) Artifacts to the same directory
In multiple arch/os scenarios, you may have Artifacts built in different jobs. To download all Artifacts to the same directory (or matching a glob pattern), you can use the pattern and merge-multiple inputs.
jobs:
upload:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: my-artifact-${{ matrix.runs-on }}
path: file-${{ matrix.runs-on }}.txt
download:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v5
with:
path: my-artifact
pattern: my-artifact-*
merge-multiple: true
- run: ls -R my-artifact
This results in a directory like so:
my-artifact/
file-macos-latest.txt
file-ubuntu-latest.txt
file-windows-latest.txt
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@v5
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
Top Related Projects
Cache dependencies and build outputs in GitHub Actions
Action for checking out a repo
Run your GitHub Actions locally 🚀
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot