跳到主要内容

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

FeatureArtifactsCache
PurposePass build outputs (across Jobs)Speed up dependency installation (across runs)
LifecycleCan set retention daysLong-term retention, LRU eviction
Access ScopeBetween Jobs in the same WorkflowAcross all runs in the same repository