Make runs fast with dependency caches, and pass build outputs between jobs or keep them for download with artifacts.
| Cache | Artifact | |
|---|---|---|
| Purpose | Speed: reuse dependencies across runs | Output: pass files between jobs / download |
| Typical content | ~/.m2, ~/.npm, Docker layers | JAR, dist/, test reports, coverage |
| Lifetime | Evicted after ~7 days unused, 10 GB per repo | Retention 1-90 days (default 90) |
| Keyed by | key: (usually a lockfile hash) | name: |
Upload and download artifact actions must use matching major versions. Check the action README for the current pair when upgrading.
Test reports: upload with if: always() so you get them even when tests fail. Keep caches keyed on lockfiles, not on branch names, so every branch benefits.