Skip to content
Latchkey

How to Reduce Artifact Size in CI for a Large Repo

Upload only what you need, exclude source maps and node_modules, and lower retention-days to keep artifacts small.

Artifacts from a large repo balloon fast because uploads scoop up more than intended. Narrow the path, exclude heavy junk with negative patterns, and cut retention so storage and upload time both drop.

Steps

  • Scope path to the exact output directory.
  • Add negative ! patterns to exclude maps, caches, and vendored modules.
  • Set retention-days low for throwaway artifacts.

Workflow

.github/workflows/ci.yml
- uses: actions/upload-artifact@v4
  with:
    name: dist
    path: |
      dist/**
      !dist/**/*.map
      !dist/**/node_modules
    retention-days: 5
    compression-level: 9

Gotchas

  • v4 zips artifacts already; compression-level trades CPU for size on compressible content.
  • Prefer a cache over an artifact for dependency trees you can rebuild.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →