Where do wasted GitHub Actions minutes actually come from?

Most wasted minutes come from runs that should never have started, and only a smaller share from runs that are slower than necessary. The usual sources are a docs-only change that triggers the full test suite, three quick pushes to a branch that produce three complete runs when only the last one matters, and a matrix that tests combinations nobody ships.

Measure before changing anything

Begin with your account or organization's billing and usage page, which shows minute consumption. Then open the repository's Actions tab and look at the run history. Each run breaks down into jobs with their durations, so you can see which workflows, jobs and matrix legs use the most time.

For GitHub-hosted runners, minutes are billed only on private repositories. The per-minute rate also depends on the runner OS: Linux is cheapest, Windows costs more, and macOS costs the most. As a result, one macOS matrix leg can cost more than several Linux jobs. GitHub-hosted jobs are also rounded up to the whole minute individually, which means many tiny jobs cost more than their combined runtime suggests.

Source of waste What it looks like in run history Fix first
Irrelevant triggers Full CI on README edits Path filters
Superseded runs Several runs per branch, only the last one reviewed Concurrency cancel
Oversized matrix Many legs with identical outcomes Matrix trimming
Slow setup Long dependency install steps Caching

Order matters

Remove runs that should never start, and cancel runs that have been superseded, before you tune caches. A faster cache on a run that should not exist still costs money. The teams that gain most from this order are busy private repositories, monorepos where most changes touch one service, and projects with large matrices.

The benefit goes beyond the bill. When fewer runs are queued, the runs that matter start sooner, which shortens queues and gives engineers faster feedback on the commit they actually pushed.

How do path filters skip irrelevant workflow runs?

The cheapest run is the one that never starts. Under on.push and on.pull_request, the paths key lists glob patterns, and the workflow triggers only if at least one changed file matches. paths-ignore does the reverse: the workflow is skipped when every changed file matches an ignored pattern. You cannot use both keys for the same event, but paths accepts ! patterns for exclusions.

Two common uses:

  • Docs-only changes. A workflow with paths-ignore set to docs/** and **/*.md stops a README typo fix from running a 20-minute integration suite.
  • Monorepo services. Each service gets its own workflow scoped to services/billing/**, so a change to billing does not build or test the search service.

When path filters cause problems

Path filters only see which files changed. They do not know your dependency graph. If billing imports libs/common/, or behavior depends on a root go.mod, package.json, Dockerfile or the workflow file itself, those paths must appear in the filter. Otherwise a change breaks the service and CI never runs.

Required status checks are the second issue. When a path filter skips a workflow, its checks are never reported. A branch protection rule that requires them leaves the pull request stuck on "Pending" indefinitely.

The usual fix is to let the workflow always trigger and move the decision into the jobs:

  1. A cheap first job diffs the changes against the base branch and exposes outputs such as billing=true.
  2. Downstream jobs gate on those outputs with if:. A job skipped by a condition does not block a required check the way a missing check does.
  3. A summary job declares needs: on the other jobs and uses if: always(). It fails if any needed job failed or was cancelled. You mark only this job as required.

This approach is reliable, but you now maintain your own change-detection logic, and every workflow run spends a few seconds of runner time before it can decide to skip anything.

name: ci
on:
  pull_request:  # no paths filter: always trigger so the required check is always reported
jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      billing: ${{ steps.diff.outputs.billing }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # full history so the base commit is available to diff against
      - id: diff
        run: |
          # List indirect dependencies too: shared lib, root config, workflow files
          if git diff --name-only "${{ github.event.pull_request.base.sha }}" HEAD \
             | grep -qE '^(services/billing/|libs/common/|go\.mod$|\.github/workflows/)'; then
            echo "billing=true" >> "$GITHUB_OUTPUT"
          else
            echo "billing=false" >> "$GITHUB_OUTPUT"
          fi
  billing-tests:
    needs: changes
    if: needs.changes.outputs.billing == 'true'  # skipped, not missing, when billing is untouched
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make -C services/billing test
  ci-summary:  # the only job marked as a required status check
    needs: [changes, billing-tests]
    if: always()  # run even when a needed job was skipped or failed
    runs-on: ubuntu-latest
    steps:
      - run: |
          # Skipped jobs are fine; failed or cancelled jobs fail the summary
          if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
            exit 1
          fi

A workflow that always triggers, detects billing-related changes (including the shared library and root config) in a cheap first job, gates the test job on that output, and reports a single always-running summary job as the required check.

How does concurrency cancel-in-progress stop superseded runs?

…it can decide whether to do any real work. Concurrency attacks a different waste: runs that are still going after a newer commit has made their result irrelevant.

A workflow-level concurrency block with group: ${{ github.workflow }}-${{ github.ref }} and cancel-in-progress: true puts every run of the same workflow on the same ref into one group. When a new run enters the group, GitHub cancels the one in progress. On a pull request, github.ref is refs/pull/<number>/merge, so each PR gets its own group. On a push, it is the branch ref. Billing stops when the cancelled job stops, so a five-minute test suite killed at minute one costs one minute.

Three quick pushes to feature/x:

  • t=0 push A: run A starts
  • t=1 push B: run A cancelled, run B starts
  • t=3 push C: run B cancelled, run C runs to completion

Only C's result matters, and only C runs in full.

Your deploy workflow on the default branch should use a group such as deploy-production with cancel-in-progress: false. A running deploy then finishes, and newer runs wait their turn. Only one run can wait in the group. If another run arrives, the waiting run is cancelled and the newest one takes its place. For deploys, that is usually what you want.

There are two common mistakes:

  • Group too broad. If the key omits github.ref, a push to one branch cancels CI on every other branch.
  • Group shared with deploys. If a test workflow and a release job share a group that has cancellation on, a routine push can kill a migration or a publish step partway through. Keep deploy and release groups separate, and keep cancellation off for them.
# .github/workflows/ci.yml
# One group per workflow + ref. A newer push to the same branch or PR
# cancels the run still in progress.
name: CI
on:
  push:
    branches-ignore: [main]
  pull_request:
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test

# .github/workflows/deploy.yml  (separate file)
# Fixed group name, cancellation off: a running deploy always finishes.
# Newer runs queue; only the most recent queued run is kept.
name: Deploy
on:
  push:
    branches: [main]
concurrency:
  group: deploy-production
  cancel-in-progress: false
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/deploy.sh production

Two workflow files: CI cancels superseded runs per branch or PR, while the production deploy uses its own group with cancellation off so an in-progress deploy is never killed.

How should you key actions/cache so it saves time instead of costing it?

actions/cache stores a directory under a key and restores it on an exact match. Build the key from the runner OS plus hashFiles('**/package-lock.json') (or poetry.lock, go.sum) so it changes only when dependencies change. Add a restore-keys prefix such as the OS-and-tool portion alone. When the lockfile changes, the job then restores the closest older cache and downloads only the difference.

Caches are branch-scoped. A pull request can read caches from its own branch and the default branch, but not from sibling branches. Each repository has a size cap, 10 GB by default. When the cap is reached, the least-recently-used entries are evicted, and entries left unused for about a week are removed.

Cache downloaded dependencies such as the npm cache directory, pip's download cache and Go's module cache. Skip build outputs that regenerate in seconds.

Approach Example Trade-off
Hand-written step actions/cache with path: ~/.npm, a key from OS plus lockfile hash, and an OS-prefix restore-keys Full control over paths and keys, but you maintain it
Setup action actions/setup-node with cache: npm, or setup-python with cache: pip; setup-go also has built-in caching Keyed on the lockfile automatically, with less to get wrong

Caching hurts in four cases:

  • Thrashing: Keys that include the commit SHA miss on almost every run.
  • Slow restores: Restore and save take longer than a fresh install.
  • Stale dependencies: Restoring node_modules through a broad restore-keys can hide a broken lockfile.
  • Cold runs: The first run on a new branch, or after a key change, pays for a full install plus a save.

Illustrative estimate (assumed numbers, not a benchmark):

Saving per run = hit rate × (install − restore) − miss rate × save

Assume a 90 s install, a 20 s restore, a 25 s save and an 80% hit rate:

0.8 × 70 − 0.2 × 25 = 51 s saved per run

If restore time approaches install time, the cache stops paying for itself.

name: ci
on: [push, pull_request]

jobs:
  hand-written:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      # Cache npm's download cache, not node_modules, so npm ci still
      # installs exactly what the lockfile says.
      - uses: actions/cache@v4
        with:
          path: ~/.npm
          # Exact key changes only when the lockfile changes.
          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
          # On a lockfile change, restore the newest older cache for this OS
          # and download only the difference.
          restore-keys: |
            ${{ runner.os }}-npm-
      - run: npm ci

  setup-action:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # Same effect: setup-node caches ~/.npm, keyed on the lockfile hash.
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci

Two equivalent jobs: one caches npm's download cache with an explicit actions/cache key and an OS-prefix restore-key, the other uses setup-node's built-in cache: npm option.

How do you trim matrices, timeouts and job ordering?

Run the full matrix where it pays off

A three-OS, four-version matrix is 12 jobs. On a pull request, most of those legs repeat what a single Linux job already tells you. Run the full matrix on pushes to main and on a nightly schedule. On pull requests, run one or two representative legs, for example Linux plus the oldest supported version. You can select the matrix with an expression on github.event_name, so a single workflow file covers both cases.

Keep fail-fast: true (the default) when one leg failing means the change is broken everywhere, such as a compile error. Set it to false only on the full matrix, where you need the complete failure picture to diagnose a platform-specific problem.

Illustrative estimate (assumed numbers, not a benchmark): saved minutes = (full legs − PR legs) × minutes per leg × PRs. With 12 versus 2 legs, 6 minutes per leg and 200 PR runs a month: 10 × 6 × 200 = 12,000 minutes.

The trade-off is that a Windows-only or old-version failure now surfaces after merge. At that point it blocks everyone on main and costs more to fix than it would have on the PR.

Bound every job

Set timeout-minutes on every job, and on individual long steps. Without it, a hung test or a stalled network call runs to the platform default of six hours. Pick a timeout of about two to three times the job's normal duration.

Order jobs so cheap failures stop expensive ones

Run lint and unit tests first. Build once, upload the build output as an artifact, and have the integration and e2e jobs declare needs: on the build and test jobs, then download that artifact. A lint error then costs a minute instead of a full e2e run, and no downstream job rebuilds what an earlier job already built.

on:
  pull_request:
  push:
    branches: [main]
  schedule:
    - cron: '0 3 * * *'   # nightly full matrix
jobs:
  lint-unit:               # cheapest checks run first
    runs-on: ubuntu-latest
    timeout-minutes: 10    # roughly 2-3x the normal duration
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run lint && npm test
  build:                   # build once, share the output
    needs: lint-unit
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with: { name: dist, path: dist/ }
  integration:
    needs: [lint-unit, build]  # skipped if lint, unit tests or build fail
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    strategy:
      # PRs: stop early. main/nightly: report every failing leg.
      fail-fast: ${{ github.event_name == 'pull_request' }}
      matrix:
        os: ${{ fromJSON(github.event_name == 'pull_request' && '["ubuntu-latest"]' || '["ubuntu-latest","windows-latest","macos-latest"]') }}
        node: ${{ fromJSON(github.event_name == 'pull_request' && '[18]' || '[18,20,22]') }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '${{ matrix.node }}' }
      - uses: actions/download-artifact@v4   # reuse build output, no rebuild
        with: { name: dist, path: dist/ }
      - run: npm ci && npm run test:integration
        timeout-minutes: 20   # cap a hung test before the job limit

One workflow that runs a single Linux leg on the oldest supported Node version for pull requests and the full 3x3 matrix on main and nightly, puts a timeout on every job, and gates artifact-based integration tests behind lint, unit tests and a single build.

Which triggers cause duplicate or forgotten runs?

Trigger lists tend to grow over time and are rarely revisited, so audit them directly:

  • Overlapping push and pull_request. A workflow that listens to push on all branches and also to pull_request runs twice for every commit pushed to a branch with an open PR. Both runs check out nearly the same code, and the pull_request run actually tests the merge result, so the push run adds little. Limit push to the default branch, where it validates merged code and feeds deployments. Let pull_request cover feature work. The example below does this: push with branches: [main] and pull_request with no branch filter.
  • Tag and release triggers. If the release workflow fires on tag pushes, check that the main CI workflow doesn't also match those tags and rebuild the same commit.
  • Scheduled workflows. schedule runs against the default branch, so the cost doesn't depend on feature branch activity. It depends on cron jobs that nobody reads anymore. For each scheduled workflow, find out who consumes its result and whether the frequency still makes sense. A nightly job could probably run weekly, and a failing job that nobody has noticed in a month should be deleted.
  • Forks. Workflows copied into forks can run on the fork owner's schedule. Add a job-level if: github.repository == 'your-org/your-repo' to scheduled jobs so they run only in the canonical repository.
  • Manual and API triggers. workflow_dispatch and repository_dispatch are cheap to keep, but check that no external automation calls them in a loop.

Put this audit on a recurring calendar reminder.

What are the alternatives to cutting wasted runs, and how do they affect cost?

Self-hosted runners and larger hosted runners are the usual alternatives to removing waste. They change the price or speed of each minute. They do not change how many minutes you consume, so treat them as a separate decision made after the waste is gone.

Option Effect on cost Trade-off
Cut wasted runs Fewer billed minutes Low effort, mostly YAML review
Larger hosted runners Shorter wall-clock time, higher per-minute rate Billed separately from included minutes
Self-hosted runners No per-minute charge from GitHub; you pay for infrastructure Patching, autoscaling, and risk from untrusted fork PRs on public repositories

Illustrative estimate (assumed numbers, not a benchmark). Assume:

  • 200 runs per day at 12 minutes each, which is 2,400 minutes per day.
  • 25% of pushes are docs-only and get skipped by path filters.
  • 15% of pushes are superseded and get cancelled about halfway through.

Saved minutes = runs × minutes × (skip share + superseded share × fraction cancelled) = 200 × 12 × (0.25 + 0.15 × 0.5) = 780 minutes per day, or roughly a third of the total.

Prioritised checklist (lowest effort and risk first)

  1. Add path filters for docs and other non-code changes.
  2. Add concurrency groups with cancel-in-progress on PR branches.
  3. Set job timeouts and remove duplicate triggers.
  4. Fix cache keys and trim the matrix.
  5. Only then evaluate larger or self-hosted runners.

The billing savings are only part of the benefit. Fewer queued jobs mean real changes start sooner, and cancelled stale runs stop competing with the commit you actually care about. Engineers spend less time waiting on checks that no longer matter.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to reduce github actions minutes, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.