Skip to content
Latchkey

How to Scope a Concurrency Group per Environment in GitHub Actions

Keying the concurrency group on the environment name keeps each target deploy lane independent.

Set concurrency.group to a key that includes the environment name. Deploys to different environments run in separate lanes, while deploys to the same one share a lane.

Steps

  • Add a job-level concurrency: block.
  • Include the environment name in group.
  • Pick cancel-in-progress per your release policy.

Workflow

.github/workflows/ci.yml
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.target }}
    concurrency:
      group: deploy-${{ inputs.target }}
      cancel-in-progress: false
    steps:
      - run: ./deploy.sh --env ${{ inputs.target }}

Gotchas

  • Omitting the environment from the group serializes all deploys into one lane.
  • For deploys prefer cancel-in-progress: false so a running release is not interrupted.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →