# Save GitHub Actions minutes with three workflow fixes

> Save GitHub Actions minutes: cancel replaced runs, skip docs-only pushes, cap jobs below the 6-hour default.

Source: https://fullbytedeveloper.com/blog/ci-minutes
Published here: 2026-11-15, updated 2026-12-03

Five pushes on one pull request can mean five full CI runs when only the last result matters. Private GitHub Actions minutes still bill for cancelled work if you stop too late. Cancel replaced PR runs, skip docs-only pushes, and set timeout-minutes under the six-hour default [1][2][3].

## Fix 1: Cancel the run you just replaced

Put a concurrency block at workflow level so only one run in the group is active. On pull requests, cancel the in-progress twin when a newer push arrives. On the default branch, leave in-progress deploys alone [2].

```yaml
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
```

`github.workflow` keeps this workflow from cancelling a differently named workflow that happens to share a branch ref [2]. Without that prefix, two workflows on `refs/pull/12/merge` can knock each other out.

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 260" role="img" aria-label="Same concurrency group: a newer PR push cancels the in-progress run">
  <defs>
    <marker id="arrowCiMinutes" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="260" rx="12" fill="#0b1f3a"/>
  <text x="24" y="36" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="16" font-weight="700">concurrency group</text>
  <rect x="24" y="52" width="200" height="72" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="36" y="80" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">push 1 to PR</text>
  <text x="36" y="104" fill="#cbd5e1" font-family="ui-monospace, monospace" font-size="14">run A in progress</text>
  <path d="M224 88 H272" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowCiMinutes)"/>
  <rect x="280" y="52" width="200" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="292" y="80" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">push 2 (same ref)</text>
  <text x="292" y="104" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">run B queued</text>
  <path d="M480 88 H528" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowCiMinutes)"/>
  <rect x="536" y="44" width="160" height="88" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="548" y="76" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14" font-weight="700">cancel-in-progress</text>
  <text x="548" y="100" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">A cancelled</text>
  <text x="548" y="120" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">B runs alone</text>
  <path d="M360 124 V156" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowCiMinutes)"/>
  <rect x="24" y="164" width="672" height="76" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="36" y="196" fill="#f8fafc" font-family="ui-monospace, monospace" font-size="14">group: ${{ github.workflow }}-${{ github.ref }}</text>
  <text x="36" y="220" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">PR: cancel replaces; main deploys: cancel-in-progress false</text>
</svg>
</figure>

*One shared concurrency group per workflow plus ref; on pull requests, the newer push cancels the older run.*

## Fix 2: Skip CI when only docs changed

If Markdown edits never affect the build artifact your required check validates, ignore those paths on the pull_request trigger [1]:

```yaml
on:
  pull_request:
    paths-ignore:
      - '**.md'
      - 'docs/**'
```

Trap: a required check that never runs stays Pending, and branch protection will not let the PR merge [1]. Either keep a tiny required workflow that always runs, or do not mark the skipped workflow as required. Docs-only ignores belong on optional lint or preview jobs more often than on the one gate that allows merge.

## Fix 3: Cap every job under six hours

Unset jobs inherit a 360-minute timeout [1]. A hung integration test can burn a full billable window. Set a ceiling above your slowest healthy run:

```yaml
jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
```

Find workflows that never mention a timeout at all:

```bash
grep -L "timeout-minutes" .github/workflows/*.y*ml
```

On this website repo that command printed:

```text
indexnow.yml
```

Open each listed file and set a per-job ceiling. `grep -L` only catches files with zero matches, so a workflow that caps one job and forgets another still needs a manual read.

## Money on the napkin

GitHub's Actions billing docs price a standard Linux runner at $0.006 per minute for private repositories [3]. Public repos on standard GitHub-hosted runners do not burn that meter the same way; the cost there is queue time and feedback lag.

Example for a private repo: 20 PRs a week, four replaced runs each, 10-minute suite.

```text
20 * 4 * 10 = 800 minutes/week
800 * 4 weeks ~= 3200 minutes/month
3200 * 0.006 ~= $19.20/month
```

One uncapped hung job at 360 minutes is $2.16 by itself. Capped at 15 minutes it is $0.09. Concurrency does not remove the need for timeouts; it only stops you paying for obsolete PR heads.

## Where teams get this wrong

Cancelling deploys on `main` with `cancel-in-progress: true` and no event guard. A second push then kills a half-finished production job.

Using one global concurrency group string across every workflow. Unrelated jobs serialize or cancel each other [2].

`paths-ignore` on the only required check, then wondering why green merges never appear.

Setting `timeout-minutes` on the workflow when you meant the job (or the reverse). Those two scopes are not the same; prefer an explicit job-level ceiling you can read next to `runs-on` [1].

## Rollout order that does not surprise night shifts

1. Add `timeout-minutes` everywhere. Lowest risk.
2. Add concurrency with PR-only cancel.
3. Add `paths-ignore` only on non-required workflows, or after branch protection is updated.

Watch the Actions bill and the "cancelled" run count for a week. If cancelled runs never appear, the concurrency group string is probably unique per run when you meant it shared per PR.

## Prove concurrency locally before you trust billing

You cannot fully simulate GitHub's concurrency manager on a laptop, but you can validate the YAML and the group expression. Push a throwaway branch, open a PR, push twice within a minute, and confirm the first run flips to cancelled while the second stays yellow then green [2]. If both runs finish, the group string is not shared the way you think (often a typo in `github.workflow` vs a hard-coded name).

Also watch deploy workflows on `main`. Trigger two harmless no-op deploys only in a non-production environment first. With `cancel-in-progress` gated to `pull_request`, both `main` runs should complete. If the second cancels the first, the expression is wrong.

## Paths-ignore versus paths

`paths` and `paths-ignore` are easy to invert under stress [1]. Prefer one style per workflow. A workflow that lists both can become hard to reason about when a file matches neither mental model. For docs-only skips, `paths-ignore` on Markdown is enough. For "only run when Go files change", use `paths` with `**/*.go` instead of ignoring everything else.

When a monorepo has packages A and B, put package filters in separate workflows or use path filters so a docs edit in A does not rebuild B. That is the same minute-saving idea at package scale.

## Matrix jobs and parallel waste

A `strategy.matrix` with four OS values times three Node versions is twelve jobs. Each one bills its own minutes on private runners [3]. Concurrency cancel still helps when the PR head moves, but it cancels the whole matrix group only if your `group` string is shared across those jobs the way you intend. If every matrix cell gets a unique group (for example by baking `matrix.os` into the group key), you can still burn twelve obsolete cells on every push.

Prefer a smaller default matrix on pull requests (one Linux, one Node) and expand to the full grid on `push` to `main` or on a nightly schedule. That pattern keeps feedback fast on PRs and keeps the expensive grid for the branch that ships.

## Billing footnotes worth reading once

Minute multipliers differ by OS and larger runners [3]. The $0.006 Linux figure is the common private-repo baseline, not a universal constant. macOS and larger machines cost more per minute, so a hung job without `timeout-minutes` hurts harder there. Free allowances and included minutes for public repositories change over time; read the current billing page when you quote a dollar number in a budget meeting [3].

For a Python type check that fails CI only on new errors, see [ty vs mypy, and how to switch without fixing old errors](/blog/ty-vs-mypy-switch-with-baseline). Before you merge a new workflow that spends those minutes, run [Check GitHub Actions before merging workflows](/blog/github-actions-five-workflow-checks). For the single-line job ceiling pattern alone, see [one line caps a hung GitHub Actions job](/blog/hung-job).

Send this to the friend who pushes five times before breakfast then wonders where Actions minutes went.

Image: Dark isometric CI floor with teal job cubes on a pipe, orange cancel wedges, a docs packet on a bypass rail, and a time cap ring closing over a long job, with no typography or logos.
https://fullbytedeveloper.com/media/ci-minutes/ci-minutes-venice.webp
Cancel replaced runs, skip docs-only pushes, and cap jobs so they cannot run for hours.

## Sources

1. [GitHub docs: workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax)
2. [GitHub docs: control workflow concurrency](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency)
3. [GitHub docs: Actions billing](https://docs.github.com/en/billing/concepts/product-billing/github-actions)
