workflow
concurrency:
Limits concurrent runs that share the same group so only one is active (and at most one pending). Set at the workflow or job level to serialize deploys or cancel superseded PR builds.
concurrency:
group: <string>
cancel-in-progress: true|false Common values / subkeys
| Value / Subkey | Purpose |
|---|---|
| group | Grouping key, usually built from workflow + ref (supports expressions) |
| cancel-in-progress | Cancel any in-progress run in the same group when a new one queues |
Examples
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true Cancel stale PR/branch builds when a new commit lands
concurrency:
group: deploy-prod
cancel-in-progress: false Serialize prod deploys, queue rather than cancel
jobs:
release:
concurrency: release-${{ github.ref }} Short-form: string is the group name
Gotcha
Only one run can be pending per group — if a third run arrives while one is running and one is pending, the pending run is cancelled, not queued.
Related keywords
on:
Declares the events that trigger the workflow. Accepts a single event, a list, or a map with per-event filters (branches, paths, tags, types).
jobs:
Top-level map of jobs that run in parallel by default. Each job has an ID (used by `needs:` and outputs) and either a `steps:` list or a `uses:` reference to a reusable workflow.
${{ github }}
The `github` context exposes information about the workflow run, event payload, repository, and actor. It is available in most expression fields and is the primary source of triggering-event data.
permissions:
Controls the scopes granted to the automatically generated GITHUB_TOKEN. Can be set at the workflow or job level; the job-level block overrides the workflow default.
env:
Defines environment variables for a scope. Declared at the workflow, job, or step level and read back via the `env` context or as real environment variables inside `run:` scripts.