What Is an Artifact in GitHub Actions?
Last updated
An artifact in GitHub Actions is a file or folder that a workflow run saves so that later jobs, or people, can use it. Typical artifacts are build outputs, test reports, coverage files and screenshots from failed end-to-end tests.
How it works
You upload with actions/upload-artifact and download with actions/download-artifact. Because each job runs on a fresh runner, artifacts are the standard way to pass build output from one job to the next. Uploaded artifacts also appear on the workflow run page, where anyone with access can download them as a zip.
Artifacts belong to a single workflow run and expire after a retention period. The default is set at repository or organization level and can be overridden per upload with retention-days.
Since version 4 of the artifact actions, artifact names must be unique within a run. Uploading twice to the same name fails unless you set overwrite. Matrix jobs therefore need a name that includes the matrix value.
Example
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
if-no-files-found: error
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- run: ls dist
Add if: always() or if: failure() to the upload step to keep reports from failed runs, which is when you need them most.
Artifacts versus caches
| Artifact | Cache | |
|---|---|---|
| Purpose | Output of this run | Speed up future runs |
| Scope | One workflow run | Shared across runs and branches by key |
| Retention | Set per run | Evicted when unused or over size limit |
| Immutable | Per name in a run | Per cache key |
If you are saving node_modules to reuse next week, use a cache. If you are handing a binary to the deploy job, use an artifact. See GitHub Actions caching.
Common mistakes
- Uploading too much. Large artifacts slow jobs and count against storage quota. Upload only what is needed.
- Name collisions in matrix jobs. Include
${{ matrix.os }}or the shard number in the name, and merge afterward withactions/upload-artifact/merge. - Secrets in artifacts. Anyone who can read the run can download them. Never upload
.envfiles or credentials. - Using artifacts as a cache. It re-uploads every run and is slower than a proper cache.
- Forgetting retention. Long defaults quietly consume storage.
Related terms
FAQ
How long are artifacts kept?
For the configured retention period, by default 90 days for public repositories unless changed. Check your repository settings for the current value.
Can artifacts be shared between workflows?
Yes, with download-artifact using the run-id and a token, or via the REST API. Within one run it is simple.
Do artifacts cost money?
Storage beyond your plan's included amount is billed. Check GitHub's billing page for current rates.
Related
- What Are CI Minutes? How Billing WorksCI minutes are the billed compute time your pipelines use. Learn how GitHub Actions counts minutes, multipliers, rounding and how to reduce usage.
- What Is a Cache Key in GitHub Actions?A cache key is the string that identifies a saved cache in GitHub Actions. Learn how keys and restore-keys work and how to avoid stale caches.
- What Is a Concurrency Group in GitHub Actions?A concurrency group makes GitHub Actions run one workflow or job at a time per key and can cancel older runs. See the YAML and common mistakes.
- What Is a Flaky Test? Definition and CausesA flaky test passes and fails on the same code without any change. Learn the common causes, how to detect them in CI and how to fix or quarantine them.