Artifacts and Cache
Artifacts
Artifacts are files generated by a Workflow run that can be passed across Jobs:
steps:
- uses: upload-artifact
with:
name: build-output
path: dist/
- uses: download-artifact
with:
name: build-output
path: ./app
Cache
Cache is used to speed up dependency installation and avoid redundant downloads:
steps:
- uses: cache
with:
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
path: ~/.npm
restore-keys: |
npm-${{ runner.os }}-
Artifacts vs Cache
| Feature | Artifacts | Cache |
|---|---|---|
| Purpose | Pass build outputs (across Jobs) | Speed up dependency installation (across runs) |
| Lifecycle | Can set retention days | Long-term retention, LRU eviction |
| Access Scope | Between Jobs in the same Workflow | Across all runs in the same repository |