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
pathto the exact output directory. - Add negative
!patterns to exclude maps, caches, and vendored modules. - Set
retention-dayslow 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: 9Gotchas
- v4 zips artifacts already;
compression-leveltrades CPU for size on compressible content. - Prefer a cache over an artifact for dependency trees you can rebuild.
Related guides
How to Cache Incremental Build Output in CICache build tool output (tsc .tsbuildinfo, webpack cache, Gradle build cache) in GitHub Actions so a large re…
How to Manage Disk Space in CI for Large ReposFree disk space in GitHub Actions when a large repository fills the runner, using df to inspect, docker prune…