10 Ways to Reduce GitHub Actions Costs
Practical strategies to cut your CI/CD bill without slowing down your team.
1. Cache Dependencies Aggressively
The actions/cache action stores npm, pip, Maven, and other package manager caches between runs. A cold install that takes 3 minutes can drop to 15 seconds with a warm cache.
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-2. Use Linux Runners Whenever Possible
Linux runners cost 1x, Windows costs 2x, and macOS costs 10x. If you only need macOS for final builds or signing, move linting, testing, and analysis to Linux.
3. Set Concurrency Limits
Use the concurrency key to cancel in-progress runs when a new commit is pushed to the same branch. This prevents wasted minutes on outdated commits.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true4. Use Path Filters
Only run workflows when relevant files change. Don't re-run your entire test suite when someone edits the README.
on:
push:
paths:
- 'src/**'
- 'tests/**'
- 'package.json'5. Split Long Workflows
Break monolithic workflows into smaller, independently-triggered jobs. Run expensive integration tests only on pull requests to main, not on every push.
6. Use Timeout Limits
Set timeout-minutes on jobs to prevent runaway processes from consuming your entire monthly allowance in a single stuck run.
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 157. Optimize Docker Builds
Use multi-stage builds and BuildKit cache mounts. Push images to a registry and pull cached layers instead of rebuilding from scratch every time.
8. Run Tests in Parallel
Use matrix strategies to parallelize test suites. Four 5-minute shards finish faster than one 20-minute sequential run, and you catch failures earlier.
strategy:
matrix:
shard: [1, 2, 3, 4]
steps:
- run: npx jest --shard=${{ matrix.shard }}/49. Use Self-Hosted Runners for Heavy Workloads
If you consistently use 10,000+ minutes/month, self-hosted runners on your own infrastructure can be cheaper. The runner software is free; you only pay for compute.
10. Monitor Usage Proactively
Don't wait for the bill. Track daily consumption, set alerts at 50%, 75%, and 90% thresholds, and use predictions to know when you'll hit your limit.
Quick Impact Summary
| Strategy | Effort | Impact |
|---|---|---|
| Caching | Low | High |
| Linux runners | Low | High |
| Concurrency | Low | Medium |
| Path filters | Low | Medium |
| Split workflows | Medium | Medium |
| Timeouts | Low | High (risk reduction) |
| Docker optimization | Medium | High |
| Parallel tests | Medium | Medium |
| Self-hosted | High | High |
| Monitoring | Low | High |
Start Monitoring Your GitHub Actions Usage
Build Quota tracks your usage, predicts overages, and sends alerts before you get an unexpected bill. Free to start.