Code Reference

Artifacts

GitHub Actions · Reference cheat sheet

Artifacts

GitHub Actions · Reference cheat sheet


📋 Overview

Artifacts persist files between jobs or after a workflow finishes (logs, builds, test reports). Upload with actions/upload-artifact, download with actions/download-artifact. Retention is limited; use releases or external storage for long-term binaries.

🔧 Core concepts

PieceRole
upload-artifactStore paths from a job
download-artifactRestore into another job/run
retention-daysOverride default retention
nameArtifact identifier
pathFile/glob to store
if-no-files-foundwarn / error / ignore

Artifacts are per-workflow-run. Jobs that need build outputs from another job must download explicitly—workspace is not shared.

💡 Examples

Build → test jobs:

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

  verify:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist
      - run: ls -R dist

Multiple paths:

- uses: actions/upload-artifact@v4
  with:
    name: reports
    path: |
      coverage/
      test-results/

⚠️ Pitfalls

  • Artifact v3/v4 APIs differ—match upload/download major versions.
  • Uploading huge node_modules wastes storage—upload only build outputs.
  • Name collisions across matrix cells—include $\{\{ matrix.* \}\} in the name.
  • Expired artifacts disappear—don’t rely on them as a package registry.
  • Sensitive files in artifacts are downloadable by users with permission—filter carefully.
  • Compression and path layout differ; always ls after download in CI once.

On this page