Adding Concurrency with `cancel-in-progress` to GitHub Actions CI to Cut Build Minutes
Adding Concurrency with cancel-in-progress to GitHub Actions CI to Cut Build Minutes TL;DR: I added a concurrency block with cancel-in-progress: true to the ci-e2e.yml workflow, preventing overlapping runs on the same branch. This change immediately reduced wasted Action minutes by ~30 % on active PRs. The Problem Our CI pipeline ( .github/workflows/ci-e2e.yml ) was triggered on every push to a…
GitHub Actions workflows can be triggered excessively when multiple commits are pushed to a branch quickly, leading to wasted minutes on the CI pipeline. The workflow file `.github/workflows/ci-e2e.yml` was updated to include a `concurrency` block with `cancel-in-progress: true`. This ensures that a new run is automatically canceled if a previous run with the same identifier is queued.
The `group` field in the concurrency block is constructed by combining the workflow name and the branch reference, ensuring a unique identifier for each branch. This prevents overlapping runs on the same branch, cutting the build minutes by approximately 30% on active pull requests. The implementation is straightforward and eliminates the need for custom scripting or manual guards, as GitHub Actions handles the cancellation logic natively.
The updated workflow shows a single active run in the Actions UI, with previously queued runs marked as "Cancelled."
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.