GitHub Actions Tutorial — Download Artifacts
Download Artifacts
Use actions/download-artifact to retrieve artifacts uploaded by earlier jobs in the same workflow, or from other workflow runs.
Download in a Later Job
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: actions/upload-artifact@v4
with:
name: build-output
path: ./dist
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-output # must match upload name
path: ./dist # where to put it
- run: ls -la ./dist
- run: echo "Deploying build output..."
Download All Artifacts
Omit name: to download everything:
steps:
- uses: actions/download-artifact@v4
# No 'name' — downloads all artifacts
- run: ls -la
# Each artifact is in a directory named after the artifact
Directory structure:
./build-output/
├── index.js
└── styles.css
./test-report/
└── results.xml
./coverage-report/
└── lcov.info
Download from Another Workflow Run
Use run-id to download artifacts from a different workflow run (common with workflow_run):
on:
workflow_run:
workflows: ["Build"]
types: [completed]
jobs:
deploy:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-output
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: ls -la
Merge Multiple Artifacts
Upload artifacts from matrix jobs and merge them:
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- run: echo "result-${{ matrix.os }}" > result.txt
- uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.os }}
path: result.txt
collect:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: results-*
merge-multiple: true
path: ./all-results
- run: ls -la ./all-results
| Option | Purpose |
|---|---|
pattern: |
Glob pattern to match artifact names |
merge-multiple: true |
Merge matched artifacts into one directory |
Common Mistakes
| Mistake | Fix |
|---|---|
| Artifact not found | The name: must match exactly what was uploaded |
| Download from different run fails | Need run-id: and github-token:
|
| Files overwrite each other | Use merge-multiple: true with unique filenames or separate paths |
| Artifact expired | Default retention is 90 days; check retention settings |
Quick Reference
| Concept | Syntax |
|---|---|
| Download one | name: artifact-name |
| Download all | Omit name:
|
| Custom path | path: ./my-dir |
| From other run |
run-id: + github-token:
|
| Merge matrix |
pattern: prefix-* + merge-multiple: true
|
← Previous: Upload Artifacts
Next: Dependency Caching →