How to reduce CI costs
Stop runs nobody needs, cache repeated work and cut billed minutes, then move builds to a faster, cheaper runner. With GitHub Actions settings and rates.

To reduce a CI bill, start with the workflows that account for most of it. Stop the runs nobody needs, cache the work every run repeats, and cut the billed minutes in what is left. All of that works on the runners you already use.
Changing the runner is one of the easiest fixes there is. You connect a provider and change the runs-on label on a compatible workflow. On Avrea, which we build, builds run 2x faster than on GitHub-hosted runners on hardware alone and 10x faster with cache hits, and a 2 vCPU Linux x64 runner costs a third less per minute.
The examples use GitHub Actions, where we can give exact settings and rates, and name the GitLab CI and CircleCI equivalent where one exists. GitHub doesn’t charge for standard runners in public repositories, so the numbers here are for private ones. Rates are GitHub’s and Avrea’s list prices, checked on 20 November 2026. GitHub runner pricing · Avrea pricing
The short version
| Change | On GitHub Actions | What it saves |
|---|---|---|
| Cancel superseded runs | concurrency with cancel-in-progress | The rest of every run a newer push replaced |
| Remove overlapping push and pull request runs | push limited to main, pull_request for branches | The second run on every push to a pull request |
| Skip work a change can't affect | Change detection in a first job, if: on the jobs behind it | Whole jobs on docs-only and unrelated changes |
| Build and test only what changed | turbo --filter, nx affected | Unaffected builds and tests in a monorepo |
| Review scheduled and bot-opened runs | schedule triggers, Dependabot groups | Runs that start without anyone pushing |
| Fail before expensive jobs start | needs, fail-fast, "Re-run failed jobs" | Jobs that would fail anyway, and full re-runs |
| Trim the pull request matrix | Distinct configurations on pull requests, the rest on main or nightly | Redundant matrix jobs, including Windows and macOS ones |
| Cache the work every run repeats | Dependency cache, the build tool's own cache, Docker layers | Install, compile and image-build minutes on every hit |
| Combine very short jobs | Steps in one job | Up to a minute of rounding per job |
| Cap hung jobs | timeout-minutes | Up to 360 billed minutes per hang |
| Match the runner to the job | Linux unless the job needs another OS, size from measured CPU and memory | The 1.7x Windows and 10.3x macOS rates, and idle cores |
| Shorten artifact retention | retention-days | Storage billed at $0.25 per GB per month |
| Move builds to a faster, cheaper runner | runs-on | A lower rate, a shorter runtime and no rounding up to the minute |
Find the workflows behind the bill
Download the detailed usage report for each of the last two billing periods from Billing & Licensing in your GitHub settings. Each row has a repository and a sku, and usage from a workflow also has its workflow_path, so summing net_amount by those three shows which workflow on which runner type the money went to. net_amount is the charge after included usage and discounts. The detailed report covers at most 31 days and only comes from the web interface. The REST API returns the summarized report, which has no workflow path. GitHub billing reports reference
Make two lists from it: the largest charges, and the largest increases between the two periods. A workflow that has been expensive for a year won’t show up as a spike. If several repositories got more expensive in the same week, check whether they picked up the same version of a shared workflow. One extra install step in a template lands on the bill of every team that uses it. If you pay through a commitment or a prepaid plan, check its terms as well: using fewer minutes lowers the invoice only when the contract lets it.
For a workflow near the top, check how its recent runs ended:
gh run list --workflow ci.yml --limit 200 --json conclusion \
--jq 'group_by(.conclusion) | map({conclusion: .[0].conclusion, runs: length})'
If many of them failed, check how much billed time went to failed runs and re-runs. To count the runs that were re-run, change the fields to --json attempt and the filter to '[.[] | select(.attempt > 1)] | length'.
Stop paying for runs nobody needs
When a pull request gets a new push, the runs for its older commits continue and are billed to the end, though nobody will read their results. A concurrency group cancels them:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
The pull request number keeps the group unique even when two contributors use the same branch name in different forks. A new push cancels the older run for that pull request. A push to main falls back to the run ID, which puts every run in a group of its own, so nothing on main is cancelled or held back. A group keyed on github.ref would also catch main: only one run in a group executes at a time and a newer pending run replaces an older one, so some commits on main would never be tested. Concurrency in GitHub Actions GitLab CI does this with “Auto-cancel redundant pipelines” and interruptible on the jobs, and CircleCI with “Auto-cancel redundant workflows”, which never cancels pipelines on the default branch.
Check for overlapping triggers. A workflow triggered by both push and pull_request with no branch filter runs twice on every push to a pull request branch, once for the branch and once for the pull request. Limit push to main and let pull_request cover the branches.
A paths filter keeps a docs-only change from starting the test suite, but it can block merges. When a path filter skips a whole workflow, its checks stay in “Pending”, and if one of them is a required check the pull request can’t merge. For a required workflow, detect changes in a first job and use its output to decide whether to run the build. A matrix skipped at the job level never produces checks for its individual configurations. Require one final job that runs with if: always(). Have it verify that detection succeeded and that the build either passed or was skipped because detection found no relevant changes. The path-filter example shows the complete check. GitHub’s notes on skipped but required checks On GitLab CI the equivalent is rules:changes on a job, and on CircleCI the path-filtering orb with dynamic configuration.
In a monorepo, scope the build and the tests to the diff. turbo run build test --filter="...[$BASE_SHA]" and nx affected -t build test --base=$BASE_SHA run only the builds and tests a change affects. BASE_SHA is the commit to compare against, and it has to exist in the clone, which the default shallow checkout doesn’t guarantee. A scoper that resolves to “nothing affected” still exits 0, so a broken import can show as a green check, and a dependency the graph doesn’t know about leaves tests out. Run scoped and full side by side on a week of pull requests before relying on it. Our guide to speeding up GitHub Actions has a complete path-detection workflow and the steps for resolving the base commit.
If your team opens draft pull requests early and pushes to them often, set the pull_request types to [opened, synchronize, reopened, ready_for_review] and put if: github.event.pull_request.draft == false on the heavy jobs. The first three types are the defaults, which an explicit list replaces. The jobs then run when the pull request is marked ready and on every push after that.
A nightly schedule workflow runs whether or not anything changed, so check that someone still uses each one’s result. For version updates, Dependabot opens a pull request, and with it a CI run, for each dependency unless you set groups in dependabot.yml, which combines matching updates into one pull request.
Failed runs are billed for the time they ran, and so is every re-run. Put cheap checks first: with needs: lint on the test and build jobs, a formatting error costs only the lint job’s billed time and the rest never starts. Make lint a required check too. If it fails, GitHub skips the dependent jobs, and a skipped job can satisfy a required check. Tests begin a little later on every run in exchange, so this pays off where lint failures are common. When a job does fail, use “Re-run failed jobs” and not “Re-run all jobs”. If a flaky job needs one full retry every ten runs, that adds about 10% to the cost of that job, plus the cost of any dependent jobs that also rerun.
A matrix multiplies the job count. Three operating systems times three runtime versions is nine jobs, and the Windows and macOS ones bill at higher rates. Keep on pull requests the configurations that catch different failures and move the rest to main or nightly, accepting that those failures then show up after merge. Remove any configurations you move from the pull request’s required checks, or future pull requests will wait for checks that never run. Leave fail-fast at its default of true, so one failure cancels the rest of the matrix.
Cache the work every run repeats
A cache saves money on any runner, as long as the job reuses what it restores. setup-node with cache: npm restores the package manager’s store, so npm ci still runs, and compilation and tests take as long as before. When compilation is most of the job, the build tool’s own cache is the one that matters: Gradle’s build cache, Bazel’s remote cache, ccache, sccache, Turborepo. On ephemeral runners these need somewhere to keep their entries between runs: the tool’s cache directory restored through the CI cache, a remote cache you host, or one your runner provider includes. In our Kafka benchmark, ./gradlew assemble took 2 minutes 10 seconds with build caching off and 52 seconds with Gradle’s remote cache warm, on the same 2 vCPU Avrea runner, at a 23% hit rate.
For Docker builds, order the Dockerfile so the dependency install comes before COPY . ., because the layer cache invalidates from the first changed instruction onward. Then export the cache, because an ephemeral runner starts without one:
- uses: docker/setup-buildx-action@v4
- uses: docker/build-push-action@v7
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
mode=max keeps the intermediate stages of a multi-stage build. Add .git to .dockerignore, or a COPY . . invalidates its layer on every commit.
Judge any cache by whole-job duration on the same commit with and without it, because restoring and saving take time too. That holds for GitLab CI’s cache keyword and CircleCI’s save_cache and restore_cache steps as well. On GitHub, cache storage is limited to 10 GB per repository by default, Docker layers stored with type=gha included, and the least recently used entries are evicted beyond that. A wide matrix that saves one cache per combination can spend its time evicting and re-saving. GitHub’s cache limits and eviction policy Our caching guide covers keys, backends and what not to cache.
Bill fewer minutes for the runs you keep
GitHub rounds each job up to a whole minute, so the number of jobs matters as well as their length. Three 15-second checks are 3 billed minutes as separate jobs and 1 as steps in a single job. Test shards work the same way. Say a test job takes 6 minutes 20 seconds, which bills as 7. Split into four shards of 2 minutes 10 seconds, each repeating the checkout and the install, the same tests bill as 12. Sharding buys a shorter wait. Add shards until the wait is acceptable and stop there. Other systems bill differently. GitLab CI counts job duration in seconds, so check how yours rounds before combining jobs.
A fixed sleep before the tests is billed on every run. Health options on the services: container, such as --health-cmd pg_isready for Postgres, hold the steps only until the database answers.
Set timeout-minutes on every job. The default is 360, so a test that hangs on a database connection is billed for six hours: $2.16 on the standard 2-core Linux runner, $15.12 on the 16-core one. A limit above the job’s slowest normal run, such as one with a cold cache, caps that. GitLab CI’s project timeout defaults to 60 minutes and each job can set its own timeout. CircleCI’s no_output_timeout stops a step that has printed nothing for a set time, which is not a cap on total runtime.
Run each job on the cheapest runner that can do it. Standard Linux x64 is $0.006 a minute, Windows $0.010 and macOS $0.062, so linting and platform-independent tests belong on Linux, and the macOS job should hold only the steps that need Xcode. Linux arm64 is $0.005 if nothing in the job depends on x64. For labeling, triage and other short automation, ubuntu-slim is $0.002 a minute. It runs in an unprivileged container with a 15-minute limit and can’t run Docker-in-Docker, so it suits short automation jobs and not heavyweight builds. GitHub-hosted runners reference GitLab CI prices runner types and sizes through cost factors, and CircleCI through the job’s resource_class, so the same check applies there.
A larger runner lowers the bill only when it cuts billed time by more than its higher rate. GitHub’s 8-core Linux runner is $0.022 a minute, 3.7 times the 2-core rate, so on compute alone a job has to finish more than 3.7 times faster on four times the cores to cost less. A build has to parallelize almost perfectly to do that. Otherwise the larger runner costs more per job and you are paying for a shorter wait, which is reasonable for the check that holds up merges. For a job that leaves most of its cores idle it is waste, so look at CPU and memory use before paying for more.
GitHub keeps artifacts for 90 days by default and bills storage beyond the plan’s allowance at $0.25 per GB per month, accrued hourly. Deleting old artifacts stops further charges but doesn’t remove what has already accrued in the billing cycle. Set retention-days on uploads nobody opens after the run. The Actions cache costs money only if an administrator has raised a repository’s limit above the included 10 GB. GitHub Actions billing
Run the builds on a faster, cheaper runner
Self-hosted runners carry no Actions charge, and you run the fleet
GitHub charges nothing for jobs on self-hosted runners. The $0.002 per minute fee it announced in December 2025 was postponed the next day and is not in effect. You pay for the machines, including the time they sit idle, and for the engineering hours that go into images, patching, autoscaling and incidents. Actions Runner Controller starts one runner pod per job on Kubernetes and scales the pool with demand, and spot instances lower the machine price for jobs that can be retried when one is reclaimed. Self-hosting fits when jobs need hardware or network access that hosted runners can’t give them and a platform team has the time to own it. Our guide to hosted, self-hosted and managed runners shows how to compare the monthly totals.
A managed runner changes the rate and the runtime
A managed runner provider operates the machines and bills per minute. Avrea is one. It runs GitHub Actions jobs on its own machines. On GitHub Actions, you keep defining workflows and storing secrets in GitHub, and GitHub still schedules the runs. After you install the GitHub App, a compatible workflow moves by changing one line:
jobs:
test:
runs-on: avrea-ubuntu-latest # was ubuntu-latest
On rate, a 2 vCPU Linux x64 runner is $0.004 a minute on Avrea against $0.006 on GitHub, which is 33% less. Linux x64 and Windows runners from 2 vCPU up are 20 to 33% below GitHub’s rate for the same vCPU count and memory.
Avrea also bills each job for the seconds it ran, rounded down, with no minimum, where GitHub rounds each job up to the next minute. A 40-second lint job is billed as 60 seconds on GitHub and as 40 on Avrea. The four test shards from earlier, at 2 minutes 10 seconds each, bill as 12 minutes on GitHub and as the 8 minutes 40 seconds they ran on Avrea. At the 2 vCPU rates that is 7.2 cents against about 3.5, before any difference in speed. So on Avrea, short jobs and extra shards cost the setup they repeat and nothing for rounding.
On runtime, Linux x64 jobs run in VMs on dedicated AMD EPYC hardware with local NVMe disks. In our Linux kernel benchmark, the same build on the same 2 vCPU size took 27 minutes 23 seconds on GitHub and 9 minutes 3 seconds on Avrea with no cache. At list prices that is 16.8 cents of runner time on GitHub and about 3.6 cents on Avrea. These come from build times, so treat them as estimates. Among customers, Teamspective’s median CI run went from 10 minutes to 4.5 after the move.
Put the two together and a job that runs twice as fast at two thirds of the rate costs a third as much. Ten minutes at $0.006 is 6 cents; five minutes at $0.004 is 2 cents. That is the 67% lower cost on our pricing page, and its scope is 2 vCPU Linux x64 at list prices with a 2x speedup, before credits, rounding and cache hits. Your speedup depends on the workload and the state of the cache.
Cache hits come on top of that, and Avrea does much of the caching work for you. The caches run in the same datacenter as the runners, so restoring one is a local read. In our cache benchmark, a 1 GB actions/cache restore took 14 seconds on GitHub and 2.9 seconds on Avrea. actions/cache from v4 and the setup actions work unchanged, package managers resolve through a local proxy, and each repository gets 25 GB of cache against GitHub’s 10. For compiled output, the runners come with a remote build cache endpoint configured for Gradle, Bazel, Go and other build tools, so the build-tool caching described earlier doesn’t need a cache server of your own. Enable build caching for Gradle and use Go 1.24 or later for the Go cache. For Rust, install sccache and set RUSTC_WRAPPER to sccache. Maven needs the build cache extension. For Nix, configure the substituter after installing Nix. With a warm ccache, the kernel build above took 24 seconds instead of 9 minutes 3 seconds, which is about 0.2 cents of runner time.
Avrea also does the sizing check from earlier in this guide. It compares each job’s CPU, memory and disk use on its recent runs with the runner’s capacity and names the label to switch to when the size is wrong. Runner right-sizing
When GitHub’s own runners are the cheaper choice
Standard GitHub-hosted runners are free for public repositories. For private ones, usage that fits inside your plan’s included compute costs nothing either, so there is no compute bill to reduce.
Test it on one workflow
Copy one build or test workflow and give it a distinct name. If it sets concurrency.group, prefix the copy’s group with avrea-trial- so both runs can finish. Change the runner label in the copy and push it on a branch. Don’t copy a workflow that deploys or publishes. The copy runs next to your existing CI on the same commits, so you can compare whole-job duration and cost before moving anything. Pay as you go includes $12 of credit a month, which covers 3,000 minutes on the 2 vCPU Linux runner, and the migration wizard can open the pull request for you. For other providers’ rates, see our runner pricing comparison.
Track cost per merged pull request next to time to green
To see whether the bill stays down, divide the pull request check charges for a set of repositories by the pull requests merged there in the same period. Include retries and superseded runs, and keep nightly builds and releases out so a release-heavy week doesn’t distort it. Compare months, not weeks: a week with many open pull requests and few merges raises the ratio with no change in CI. Read it next to the 95th-percentile time from the last push to the last required check passing, queue time included. If a change lowers cost per merge but makes the slowest pull requests wait longer, keep the faster runner on the job that holds up the merge and try the cheaper one on jobs that finish with time to spare.
How other teams cut their CI time
These are engineering teams’ own accounts of the same work.
- Linear’s test suites almost quadrupled in 2026. It still brought pull request wait time from more than 6 minutes to just over 5 and roughly halved runner time per test, and moving to faster third-party runners made its jobs 34% faster on average. AI coding has made CI a bottleneck, so we reworked ours to keep up (2026)
- Stripe runs about 5% of its Ruby test suite on an average build, by recording which files each test reads and running only the tests a change touches. Selective test execution at Stripe (2026)
- Shopify selects the tests to run for each change in a suite of more than 150,000 and saves about 25% of compute time. Spark joy by running fewer tests (2020)
- Slack stopped rebuilding its frontend for end-to-end runs when no frontend code had changed, which took the average build from about 5 minutes to about 2. Optimizing our E2E pipeline (2025)
- Tinybird logged every test’s execution time and used that data to cut its CI pipeline time by 60%, on GitLab. How we cut our CI pipeline execution time in half (2023)