How to speed up GitHub Actions: 10 fixes, from cache to runner size

Last updated

Remove work before you buy speed

1 / 6

Find the slow step

The run page shows each job's duration, and each step's when you open the job. Sort the slowest job's steps into four buckets: install, build, test and waiting. Each bucket has its own fix.

Read that part

2 / 6

Skip and cancel runs

A change to the README does not need the test suite: paths-ignore skips the whole workflow. When an author pushes twice in a minute, a concurrency group cancels the first run. Both save whole runs.

Read that part

3 / 6

Cache dependencies and Docker layers

Most setup-* actions cache for you with one input. Each hosted job starts with an empty Docker daemon, so docker build rebuilds every layer unless you give it a cache: two lines with docker/build-push-action.

Read that part

4 / 6

Run jobs and test shards side by side

Jobs run in parallel unless needs: chains them: the workflow takes as long as its slowest job, not the sum. A long suite splits into shards that run as a matrix, which only helps if the runners are free.

Read that part

5 / 6

Keep the checkout shallow

actions/checkout is already shallow. The slow checkouts are the ones that set fetch-depth: 0 for every job, and those that pull Git LFS files they don't use.

Read that part

6 / 6

A bigger or faster runner, last

It helps CPU-bound builds and tests, and does little for jobs that mostly wait on the network. On GitHub a 4-core minute costs twice a 2-core one, so a bigger runner pays for itself only if the job runs in less than half the time.

Read that part

The fixes of this page, in its order. GitHub's and the tools' documentation, read on 8 November 2026.

To speed up GitHub Actions, first find the slow step, then remove work before you buy speed: skip runs that can't fail, cancel superseded ones, cache dependencies and Docker layers, and run independent jobs and test shards in parallel. A bigger or faster runner comes last: it helps CPU-bound builds and tests, and does little for jobs that mostly wait on the network.

Fix Saves Effort
1. Measure the slow step Tells you which fix to pick Minutes
2. Skip runs with paths-ignore Whole runs One block of YAML
3. Cancel superseded runs with concurrency Whole runs Three lines
4. Cache dependencies Install time, every job One input
5. Cache Docker layers Image build time Two lines
6. Run jobs side by side with needs Wall-clock time Restructure
7. Shard the test suite Wall-clock time A matrix
8. Keep the checkout shallow Clone time on big repos Check one input
9. A bigger runner CPU-bound steps One label, a higher rate
10. A faster or cheaper runner Depends on the provider One label, a new vendor

The GitHub facts on this page were read on GitHub's and the tools' own documentation on 8 November 2026. flockvm sells GitHub Actions runners: fix 10 says what ours do and don't do for speed.

1. Measure first: where do the minutes go?

The run page shows each job's duration, and each step's when you open the job. From the terminal, the GitHub CLI prints the same:

gh run list --limit 10                     # recent runs and their duration
gh run view <run-id> --verbose             # jobs and their steps
gh run view <run-id> --json jobs \
  --jq '.jobs[] | {name, startedAt, completedAt}'
gh run view --log --job <job-id>           # the full log of one job

Read the slowest job's steps and sort them into four buckets: install (dependencies, browsers, toolchains), build, test, and waiting (queued before the job started, pulling images, uploading artifacts). Each bucket has its own fix below. Time spent queued before the first step is a runner or concurrency limit, not a workflow problem.

Which fix, for which slow step

Where do the minutes go?

Install: dependencies, browsers, toolchains

Cache dependencies

Most setup-* actions cache for you with one input. A cache of a few hundred megabytes saves a lot; one of 5 GB can take as long to restore as the install it replaces, so measure before and after.

Read that part

Build: Docker images with no layer cache

Cache Docker layers

Each hosted job starts with an empty Docker daemon, so docker build rebuilds every layer unless you give it a cache. Order the Dockerfile so the layers that change least come first.

Read that part

Test: a suite running on one runner

Shard the test suite

A long suite splits into shards that run as a matrix. Four shards that each take a quarter of the time only help if four runners are free.

Read that part

Waiting: queued for a free runner

A runner or concurrency limit

Time spent queued before the first step is a runner or concurrency limit, not a workflow problem. A run that a new push made useless still holds a runner: a concurrency group cancels it.

Read that part

A CPU-bound step

A bigger runner

More vCPUs help when a step can use them: a compiler, a test runner with one worker per core, a Docker build with parallel stages. Run the job once on each size and compare the step timings.

Read that part

The four buckets of this section and the CPU-bound step of fix 9, each with the fix this page gives it.

2. Don't run what can't fail

A change to the README does not need the test suite. paths-ignore skips the whole workflow "when all the path names match patterns in paths-ignore":

on:
  pull_request:
    paths-ignore:
      - "docs/**"
      - "**.md"

Its opposite, paths, runs a workflow only when some files change, which suits a monorepo with one workflow per package. One caution: a workflow skipped this way never reports, so a required status check for it stays pending. Keep required checks on workflows that always run, or make the skipped jobs report.

3. Cancel runs that a new push made useless

When an author pushes twice in a minute, the first run is wasted work that still holds a runner. A concurrency group cancels it:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

On pull_request workflows, GitHub's docs give a variant keyed on the branch, which falls back to the run ID when there is none:

concurrency:
  group: ${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

Keep cancel-in-progress off for deploy workflows on main: there you want each run to finish.

4. Cache dependencies

Most setup-* actions cache for you with one input: setup-node (npm, Yarn, pnpm), setup-python (pip, pipenv, Poetry), setup-java (Gradle, Maven), setup-go, setup-dotnet, and ruby/setup-ruby for gems.

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v4
    with:
      node-version: 22
      cache: npm
  - run: npm ci

For anything else, actions/cache with a key that changes when the lockfile does, and restore-keys to fall back on the closest older cache:

- uses: actions/cache@v4
  with:
    path: |
      ~/.cache/pip
      .venv
    key: ${{ runner.os }}-py-${{ hashFiles('requirements.lock') }}
    restore-keys: |
      ${{ runner.os }}-py-

Two limits to know: "By default, the limit is 10 GB per repository", beyond which the least recently used caches go first, and a cache not read for 7 days is removed. A cache of a few hundred megabytes saves a lot; one of 5 GB can take as long to restore as the install it replaces, so measure (fix 1) before and after.

5. Cache Docker layers

Each hosted job starts with an empty Docker daemon, so docker build rebuilds every layer unless you give it a cache. With docker/build-push-action, the GitHub Actions cache backend is two lines:

- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
  with:
    context: .
    push: false
    cache-from: type=gha
    cache-to: type=gha,mode=max

mode=max also caches the layers of intermediate stages, which is what makes multi-stage builds fast. The GitHub cache shares the 10 GB per repository with your dependency caches, so large images often fit better in a registry cache:

    cache-from: type=registry,ref=ghcr.io/acme/app:buildcache
    cache-to: type=registry,ref=ghcr.io/acme/app:buildcache,mode=max

Order the Dockerfile so the layers that change least come first: copy the lockfile and install dependencies before you copy the source.

6. Run independent jobs side by side

Steps in one job run one after another. Jobs run in parallel unless needs: chains them. Lint, type-check and unit tests rarely depend on each other:

jobs:
  lint:
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: npm ci && npm run lint }]
  typecheck:
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: npm ci && npx tsc --noEmit }]
  test:
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: npm ci && npm test }]
  deploy:
    needs: [lint, typecheck, test]
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: ./deploy.sh }]

The workflow now takes as long as its slowest job, not the sum. The trade: each job repeats its checkout and install, so this pays when the install is cached (fix 4) and each job does real work. On GitHub-hosted runners, more jobs also means more rounded-up minutes.

7. Shard the test suite

A long suite splits into shards that run as a matrix. Playwright does it with --shard:

jobs:
  e2e:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22, cache: npm }
      - run: npm ci && npx playwright install --with-deps chromium
      - run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

Jest (--shard), pytest (with plugins such as pytest-split) and Go (go test per package) split the same way. A matrix can generate up to 256 jobs per run, but your plan or runner caps how many run at once (20 jobs on GitHub Free, 60 on Team), and strategy.max-parallel caps a single matrix. Four shards that each take a quarter of the time only help if four runners are free.

8. Keep the checkout shallow

actions/checkout is already shallow: "Only a single commit is fetched by default." The slow checkouts are the ones that set fetch-depth: 0 for every job when only a release or changelog job needs the history, and those that pull Git LFS files they don't use (lfs is false by default). In a large monorepo, sparse-checkout fetches only the folders a job needs:

- uses: actions/checkout@v4
  with:
    sparse-checkout: |
      packages/api
      packages/shared

9. A bigger runner

More vCPUs help when a step can use them: a compiler with -j"$(nproc)", a test runner with one worker per core, a Docker build with parallel stages. They do little for a job that spends its time downloading, waiting on a service or running one single-threaded process.

On GitHub, ubuntu-latest in a private repository has 2 CPUs and 8 GB of RAM. Larger runners go up to 64 cores, at $0.012 a minute for 4 cores, $0.022 for 8 and $0.042 for 16 (Linux x64), and "are only available for organizations and enterprises using the GitHub Team or GitHub Enterprise Cloud plans". Since a 4-core minute costs twice a 2-core one, a bigger runner pays for itself only if the job runs in less than half the time. Run the job once on each size and compare the step timings from fix 1 before you switch the whole workflow.

10. A faster or cheaper runner

Third-party runners change one runs-on: label. What they sell differs, and so does what they can do for speed:

  • Faster CPUs than GitHub's standard runners, which shortens CPU-bound steps.
  • Caches next to the runner: dependency and Docker layer caches on the provider's own storage instead of GitHub's cache service. Blacksmith sells Docker layer caching and sticky disks at $0.50 per GB a month on its Ubuntu runners and advertises "4x faster cache downloads"; Namespace has cache volumes that are "backed by high-performance local storage". flockvm vs Blacksmith goes through Blacksmith's offer.
  • More vCPUs for the money, which turns fix 9 into a saving instead of a cost.

Every provider publishes its own speed figures, measured on its own builds: run your slowest workflow on each one before you believe any of them, ours included. flockvm runs CI jobs from the first plan payment: its 7-day trial covers VMs only, and CI jobs are held until then (CI during the trial).

flockvm is a runner of the third kind. runs-on: flockvm gives a job 4 vCPU and 8 GB for $0.004 a minute, less than GitHub's 2-core runner at $0.006, so a CPU-bound job gets twice the cores for less, counted by the second. What it does not do for speed: every job cold-boots a new Firecracker microVM, about 25 seconds before the first step (billed), and nothing is cached between jobs: no Docker layers, no dependency folder. Fixes 4 and 5 still apply, through GitHub's cache or a registry. And capacity is small: at most 4 runner VMs at once across all organizations today, Linux x64 and private repositories only, so a 4-shard matrix (fix 7) runs in one wave, on flockvm-small or on flockvm, only when no other job holds a runner and the host has room; while other organizations' jobs run, shards queue for longer. It wins on price per vCPU, not on cache. Deleting the VM after each job is a security choice, explained in self-hosted runner security, and it is what makes every cache start empty. CI limits lists them all, workflow examples has Docker, Playwright and matrix workflows that run as they are, and GitHub Actions runners on Firecracker sums it up.

For the price side of the same choice, see GitHub Actions pricing and our cheap GitHub Actions runners comparison.

What a minute costs as the runner grows

USD per minute, Linux x64. GitHub's runner pricing reference, read on 8 November 2026; flockvm's own rate, counted by the second. On flockvm every job cold-boots a new VM, about 25 seconds before the first step (billed), and nothing is cached between jobs. And capacity is small: at most 4 runner VMs at once across all organizations today, Linux x64 and private repositories only.

FAQ

Why is my GitHub Actions job slow?

Usually one of four things: installing dependencies with no cache, building Docker images with no layer cache, a test suite running on one runner, or waiting in the queue for a free runner. Open the job, sort its steps by duration, and fix the longest first.

Does a larger runner make GitHub Actions faster?

For CPU-bound steps, yes: compiling, tests with one worker per core, parallel Docker stages. For network-bound or single-threaded steps, barely. On GitHub a 4-core runner costs twice a 2-core one per minute, so time both before switching.

How do I cache Docker layers in GitHub Actions?

With docker/build-push-action, set cache-from: type=gha and cache-to: type=gha,mode=max to use GitHub's Actions cache, or type=registry with a ref to keep the cache in a container registry, which suits large images better than the 10 GB per-repository Actions cache.

Does actions/cache work on self-hosted runners?

Yes. actions/cache and the cache: input of setup-* actions store caches on GitHub's cache service, which self-hosted runners reach the same way as hosted ones. On a runner that starts empty for each job, it is the way to keep dependencies between jobs.

How do I stop running GitHub Actions on documentation changes?

Add paths-ignore with your docs paths under on.pull_request and on.push. Make sure no required status check depends on that workflow, or the skipped check stays pending.

Run your agents in their own microVMs

flockvm gives each coding agent a Firecracker microVM that pauses with its memory and resumes, billed per second. France is live, and you can start with a 7-day free trial.

Start your 7-day free trial

Card required. Nothing charged for 7 days.