DEV Community

Sohana Akbar
Sohana Akbar

Posted on

Auto-cancel Redundant GitHub Actions — Save 40% Runner Time

If you’re paying for GitHub Actions minutes, you’re probably wasting money. Every time you push new commits while a previous workflow is still running, those old runs become pointless. But they keep burning through your runner time anyway.

The fix is simple: auto-cancel redundant workflows.

The Problem
Picture this: You push a commit. Tests start running. Before they finish, you push a second commit with a tiny typo fix. Now two workflows are running simultaneously — one on an outdated commit you no longer care about.

That first run is garbage. But GitHub still charges you for every minute of it.

Multiply this across your team. Across multiple PRs. Across the entire day. You're easily looking at 30–50% wasted runner time.

The Solution
One YAML block inside your GitHub Actions workflow:

yaml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
That’s it.

group — creates a named queue per workflow + branch. Only one run from this group runs at a time.

cancel-in-progress — kills the older run immediately when a new one arrives.

Real-World Results
At a previous company, we added this to all PR-triggered workflows. Our monthly runner minutes dropped from ~45,000 to ~27,000.

40% saved. Zero effort after setup.

Where to Use This
✅ Pull request checks (test, lint, build)

✅ Push-triggered workflows on the same branch

✅ Deployment jobs where only the latest matters

Where NOT to Use It
❌ Release workflows (you want each to complete)

❌ Scheduled workflows with overlapping logic

❌ Matrix builds you actually need in parallel

Pro Tip
Combine with branch‑level rules:

yaml
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
This cancels on feature branches but protects your main branch builds.
A three-line change. Five minutes of work. Potentially thousands of saved runner minutes per month.

If you're paying for GitHub Actions, this is the lowest‑hanging fruit in your CI bill.

Go add concurrency to your workflows today.

Top comments (0)