# How to Speed Up GitHub Actions Workflows

> Speed up GitHub Actions in ten steps: measure, skip and cancel runs, cache dependencies and Docker layers, shard tests, then pick a bigger or faster runner.

- URL: https://flockvm.com/learn/speed-up-github-actions
- Last updated: 2026-11-10

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:

```bash
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.

## 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`":

```yaml
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:

```yaml
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:

```yaml
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.

```yaml
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:

```yaml
- 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:

```yaml
- 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:

```yaml
    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:

```yaml
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`:

```yaml
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:

```yaml
- 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](/compare/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](/docs/billing/trial#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](/learn/ephemeral-github-actions-runners), 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](/learn/self-hosted-runner-security), and it is what makes every cache start empty. [CI limits](/docs/ci/limits) lists them all, [workflow examples](/docs/ci/workflows) has Docker, Playwright and matrix workflows that run as they are, and [GitHub Actions runners on Firecracker](/github-actions-runners) sums it up.

For the price side of the same choice, see [GitHub Actions pricing](/learn/github-actions-pricing) and our [cheap GitHub Actions runners](/compare/cheap-github-actions-runners) comparison.

## 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.

## Sources

- [GitHub Docs: Dependency caching reference (actions/cache, restore-keys, 10 GB per repository, setup-* caching)](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching) (accessed 2026-11-08)
- [GitHub Docs: Workflow syntax (paths-ignore, needs, strategy)](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax) (accessed 2026-11-08)
- [GitHub Docs: Control the concurrency of workflows and jobs](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency) (accessed 2026-11-08)
- [GitHub Docs: Actions limits (matrix of 256 jobs, concurrency per plan)](https://docs.github.com/en/actions/reference/limits) (accessed 2026-11-08)
- [GitHub Docs: Actions runner pricing (larger runners)](https://docs.github.com/en/billing/reference/actions-runner-pricing) (accessed 2026-11-08)
- [GitHub Docs: GitHub-hosted runners reference (ubuntu-latest specs)](https://docs.github.com/en/actions/reference/runners/github-hosted-runners) (accessed 2026-11-08)
- [actions/checkout README (fetch-depth default, sparse-checkout, lfs)](https://github.com/actions/checkout) (accessed 2026-11-08)
- [Docker Docs: Cache management with GitHub Actions (type=gha, type=registry)](https://docs.docker.com/build/ci/github-actions/cache/) (accessed 2026-11-08)
- [Playwright docs: Sharding](https://playwright.dev/docs/test-sharding) (accessed 2026-11-08)
- [Blacksmith pricing (Docker layer caching, sticky disks, cache downloads)](https://www.blacksmith.sh/pricing) (accessed 2026-11-08)
- [Namespace pricing (cache volumes on local storage)](https://namespace.so/pricing.md) (accessed 2026-11-08)
- [GitHub CLI manual: gh run view](https://cli.github.com/manual/gh_run_view) (accessed 2026-11-08)
