How to Reduce GitHub Actions Minutes Usage

Cut GitHub Actions minutes with path filters, concurrency cancellation, dependency caching, smaller matrices, job timeouts and the right runner choice.

Published

At a glance

Last reviewed
Versions referenced
actions/checkout@v7 actions/cache@v6 actions/setup-node@v7
Reading time
4 min read

Code samples are not run in a live repository. See our editorial standards.

On this page

The fastest ways to reduce GitHub Actions minutes usage are to skip runs that don’t need to happen (paths-ignore), cancel superseded runs (concurrency with cancel-in-progress: true), and shorten the jobs that remain (caching, smaller matrices, timeout-minutes). The sections below are ordered by typical payoff.

Know what you are billed for

Billing applies to private repositories on GitHub-hosted runners. Usage is free for standard GitHub-hosted runners in public repositories and for self-hosted runners. For private repositories, each account gets a quota of free minutes and storage that depends on its plan, and usage beyond it is billed.

Each job’s runtime is rounded up to the next whole minute, so a Linux job that runs 62 seconds counts as 2 minutes. Minute multipliers then apply to your included quota: Linux is 1x, Windows is 2x, and macOS is 10x. A 5-minute macOS job therefore consumes 50 included minutes.

Jobs in a matrix or in parallel are each billed separately. Parallelism shortens wall-clock time but does not reduce the total.

The organization usage metrics show where minutes go, but they do not apply minute multipliers. Use them to find expensive workflows, not to reconcile your invoice.

Skip runs that don’t need to happen

Add paths-ignore to the trigger so documentation-only changes never start the workflow:

on:
  push:
    branches: [main]
    paths-ignore:
      - 'docs/**'
      - '**.md'
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**.md'

If every changed file matches an ignored pattern, no run is created. Use **.md rather than *.md: the latter matches only Markdown files in the repository root.

To run only for specific directories, use paths instead. You can’t use paths and paths-ignore for the same event in one workflow. To combine both, use paths with ! negation patterns:

on:
  pull_request:
    paths:
      - 'src/**'
      - '!src/**/*.md'

Order matters: a ! pattern only excludes files matched by an earlier positive pattern.

Pitfall: if a skipped workflow is a required status check in branch protection, the check stays in a pending state and blocks the merge. Either don’t path-filter required workflows, or add a lightweight always-running job that reports the required check name.

Cancel superseded runs

Put a concurrency group at the workflow level so a new push cancels the older run on the same ref:

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

github.head_ref is set only on pull request events, so the expression gives each PR and each branch its own group. Without cancel-in-progress, a new run only replaces runs that are still pending, not ones already executing.

Don’t cancel runs that must finish, such as deployments or release builds. Make the cancellation conditional:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

Here, runs on main complete, while runs on any other branch are cancelled when a newer commit arrives.

To verify, push two commits in quick succession. The older run in the Actions tab ends with a “Cancelled” status.

Cap runaway jobs

Set timeout-minutes on every job. The default job timeout is 360 minutes, so a hung test or a stuck network call can burn six hours of runner time.

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15

Set the value to roughly twice your normal job duration. A job that hits the limit is cancelled and shows as failed.

Cache dependencies

Caching shortens install steps, which are billed like any other step. GitHub-hosted runners start from a clean image, so without a cache each run downloads every dependency.

- uses: actions/checkout@v7
- uses: actions/cache@v6
  with:
    path: ~/.npm
    key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
    restore-keys: |
      npm-${{ runner.os }}-

The key changes whenever the lock file changes, and restore-keys falls back to the most recent cache for the same OS. For Maven, cache ~/.m2/repository keyed on hashFiles('**/pom.xml'). For Gradle, cache ~/.gradle/caches and ~/.gradle/wrapper.

Language setup actions can do this for you. For example, actions/setup-node@v7 with cache: npm handles the npm cache without a separate step.

To verify, run the workflow twice. On the second run, the cache step’s log should report a restore from the key you defined, and the install step should finish noticeably faster.

Shrink matrices

Each matrix combination is a separate job with its own rounding and OS multiplier. Remove combinations you don’t need, and keep the expensive OSes for a narrow set of versions.

jobs:
  test:
    strategy:
      matrix:
        include:
          - node-version: 22
            os: ubuntu-latest
          - node-version: 24
            os: windows-latest
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm test

A full 2 versions x 2 operating systems matrix runs four jobs. The two entries above run two jobs. With similar durations, the Windows job costs twice a Linux job, so dropping the Windows combinations saves the most.

A common pattern is to run the full matrix only on main or on a schedule, and a single Linux job on pull requests.

Choose runners deliberately

Self-hosted runners don’t consume GitHub-hosted minutes. You pay for the hardware, maintenance and security instead. They also give you access to internal networks and custom hardware.

Never attach self-hosted runners to public repositories that run untrusted pull request code. A malicious PR can execute arbitrary commands on your machine.

Larger GitHub-hosted runners are always billed per minute and don’t draw on your included minutes. They pay off only when more cores cut runtime by more than the higher per-minute rate. Measure a representative job on both before switching.

Verify the savings

  1. Push a docs-only commit. No new workflow run should appear in the Actions tab for the filtered workflow.
  2. Push two code commits in a row. The earlier run should end as “Cancelled”.
  3. Compare job durations before and after caching or matrix changes in the run summary.
  4. Check your plan’s usage in the account or organization billing settings after a few days and compare it with the previous period.

Spotted an error? Report it on our Contact page and see our editorial standards for how we correct articles.