name: 'Usage of download-artifact GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R
Download Artifact
Automatically download all artifacts from a GitHub Actions workflow, each stored in its designated directory for organized access and management
What is download-artifact GitHub Action?
The @actions/download-artifact
action is designed to simplify the process of downloading artifacts from completed workflow runs. This action is internally powered by the @actions/artifact
package, ensuring robust and reliable artifact handling.
How to Download a Single Artifact to Specific Directories in GitHub Actions
Sometimes you may want to download an artifact to the default working directory or to a path you specify. This way, downloading the artifact using the GitHub Action @actions/download-artifact, here is how you would download an artifact to a location other than the default workspace location within a workflow.
steps:
- uses: actions/download-artifact@v4
with:
name: my-artifact
- name: Display structure of downloaded files
run: ls -R
Downloading an Artifact to a Specific Directory
If you need to download an artifact to a specific directory, you can specify the path where the artifact should be stored. This is useful for organizing downloads or preparing for subsequent steps that expect files in certain locations.
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
How to Download All Artifacts
In scenarios where multiple artifacts are generated during a workflow, you may need to download all of them for further processing or analysis. GitHub Actions provides a straightforward method to handle this by using the @actions/download-artifact
action. This guide will show you how to configure your workflow to download all artifacts and manage their storage efficiently.
steps:
- uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R