Day 33beginnerMar 5, 2026

Share Build Outputs Between CI/CD Jobs with Artifacts

Artifacts let you pass build outputs between jobs so you build once and deploy the exact same binary everywhere.

cicdgithub-actionsautomation
Share:

What

Artifacts let you persist files between jobs in a GitHub Actions workflow. Upload build outputs, test reports, or compiled binaries in one job using actions/upload-artifact, and download them in subsequent jobs using actions/download-artifact. Each job runs on a fresh runner, so artifacts are the official way to share files across jobs.

Why It Matters

Without artifacts, every job would need to rebuild your application from scratch, wasting CI minutes and risking inconsistencies. Artifacts ensure the exact binary you tested is the one you deploy β€” no rebuild required. They also preserve test reports and logs for post-run analysis.

Example

# .github/workflows/build-deploy.yml
name: Build and Deploy
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with:
          name: build-output
          path: dist/
          retention-days: 7  # Clean up after 7 days

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: build-output
          path: dist/
      - name: Deploy to server
        run: |
          echo "Deploying build artifacts..."
          ls -la dist/
yaml

Common Mistake

Not setting retention-days on artifacts, causing storage costs to grow. The default retention is 90 days, and large build outputs can add up fast. For ephemeral artifacts like test reports, 1-3 days is usually enough.

Quick Fix

Always set retention-days on upload-artifact. Use 1-3 days for test reports, 7 days for build outputs, and only use the 90-day default for release binaries you might need to debug later.

Key Takeaways

  • 1Each GitHub Actions job runs on a fresh runner β€” files don't persist
  • 2Use actions/upload-artifact@v4 to save files after a job
  • 3Use actions/download-artifact@v4 to retrieve files in the next job
  • 4Set retention-days to control how long artifacts are stored
  • 5Build once, test once, deploy the same artifact everywhere

Was this tip helpful?

Help us improve the DevOpsPath daily collection

Share: