How to Upload Build Artifacts in GitHub Actions
Artifacts let you persist build output, test reports, or logs and hand them to a later job.
Use actions/upload-artifact to store files after a job and actions/download-artifact to retrieve them in a downstream job that needs: the producer.
Upload then download
Name the artifact on upload; reference the same name on download in a dependent job.
.github/workflows/ci.yml
jobs:
build:
steps:
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
deploy:
needs: build
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/Gotchas
- v4 artifacts are immutable - uploading the same
nametwice in one run fails. Use a unique name (e.g. with${{ matrix.os }}). - Default retention is 90 days (or your org limit); set
retention-daysto expire sooner and save storage. - Artifacts are zipped; very large trees are slow. Prefer caches for dependencies and artifacts for outputs.
Related guides
How to Cache Dependencies in GitHub Actions (Every Ecosystem)Cache dependencies in GitHub Actions with actions/cache - correct keys and paths for npm, yarn, pnpm, pip, Ma…
How to Use Matrix Builds in GitHub ActionsUse GitHub Actions matrix builds to test across versions and OSes in parallel - strategy.matrix, include/excl…