Upload and Download Build Artifacts

Share files between jobs using GitHub Actions artifacts. Covers uploading build outputs, test reports, and coverage data, and downloading them in dependent jobs.

Advanced

Detailed Explanation

Build Artifacts in GitHub Actions

Artifacts let you persist files from a workflow run — build outputs, test reports, logs, coverage data — and share them between jobs or download them after the workflow completes.

Workflow YAML

name: Build & Test

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run build

      - name: Upload build output
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: ./dist
          retention-days: 7

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test -- --coverage

      - name: Upload coverage report
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: coverage
          path: coverage/

  deploy:
    needs: [build, test]
    runs-on: ubuntu-latest
    steps:
      - name: Download build artifact
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: ./dist

      - name: Deploy
        run: |
          ls -la ./dist
          echo "Deploying build output..."

Key Features

Feature Description
retention-days How long to keep the artifact (1-90 days, default 90)
if: always() Upload even if previous steps failed (great for test reports)
compression-level 0-9, where 0 is no compression (default 6)
overwrite Replace existing artifact with same name (default false)

Artifact vs Cache

Artifact Cache
Purpose Share outputs, download results Speed up dependency installation
Lifetime Configurable retention (1-90 days) Evicted after 7 days of no access
Visibility Visible in workflow run UI Hidden, automatic
Size limit 500 MB (free), 2 GB (paid) 10 GB per repository
Cross-job Yes, via download-artifact No (same job only)

Downloading Multiple Artifacts

- uses: actions/download-artifact@v4
  # No name specified — downloads ALL artifacts
  with:
    path: ./artifacts

Each artifact is placed in a subdirectory named after the artifact. Use this pattern for aggregation jobs that need outputs from multiple build jobs.

Use Case

Sharing build outputs between CI and deployment jobs, preserving test reports for debugging failed runs, collecting coverage data from parallel test jobs, or archiving release binaries for download.

Try It — GitHub Actions Workflow Builder

Open full tool