/config/github-actions/concurrency-cancel-in-progress
GitHub Actions concurrency: cancel-in-progress for older runs
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 1.7.12updated 2026-10-20
- tool
- GitHub Actions
- file
- .github/workflows/*.yml
- key
- concurrency
- type
- string group, or { group, cancel-in-progress }
- default
- no limit: every run executes
concurrency puts runs with the same group key in a queue: at most one runs and one waits. With cancel-in-progress: true, a new run cancels the one in progress instead of waiting. Keyed on the workflow and the branch, this stops a pull request from running CI for every intermediate push.
The usual setting
mkdir -p .github/workflows
cat > .github/workflows/ci.yml <<'EOF'
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: echo "testing ${{ github.sha }}"
EOF
actionlint -no-color .github/workflows/ci.yml && echo "actionlint: no problems"Output
actionlint: no problems
github.head_ref is the PR branch, so all pushes to one PR share a group. The expression in cancel-in-progress cancels superseded runs on pull requests, but lets every push to main finish.
Keys
| Key | Meaning |
|---|---|
| group | any string or expression; runs with the same value are serialised |
| cancel-in-progress | true cancels the running member of the group when a new run arrives; can be an expression |
| (job level) jobs.<id>.concurrency | the same, for a single job such as a deployment |
Deployments
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: deploy-production
cancel-in-progress: false # never cancel a deployment halfwaySources
Related pages
cheat sheets · github-actionsGitHub Actions cheat sheet: triggers, jobs, matrix, outputs and cachingGitHub Actions cheat sheet: triggers, jobs and needs, matrix builds, if conditions, step and job outputs, secrets and env, caching, artifacts, contexts.commands · github-actionsactionlint: lint GitHub Actions workflows before you pushactionlint checks .github/workflows files for syntax errors, bad expressions, untrusted input in run scripts, deprecated commands and outdated actions.errors · github-actionsGitHub Actions: Resource not accessible by integration (HTTP 403)A workflow gets 403 Resource not accessible by integration when GITHUB_TOKEN lacks a scope like pull-requests: write, or the run is for a fork pull request.