Skip to content
Latchkey

How to Limit a Single Job With Concurrency in GitHub Actions

Placing the concurrency block under a job scopes serialization to that job alone, not the entire workflow.

Concurrency can sit at the workflow level or under an individual job. Putting it on the deploy job lets build and test keep running in parallel while only deploys are serialized.

Steps

  • Leave the workflow-level concurrency out (or keyed loosely).
  • Add a concurrency: block inside the specific job.
  • Use a stable group for that job so its runs queue.

Workflow

.github/workflows/ci.yml
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: npm test
  deploy:
    needs: test
    runs-on: ubuntu-latest
    concurrency:
      group: deploy-${{ github.ref }}
      cancel-in-progress: false
    steps:
      - run: ./deploy.sh

Gotchas

  • Job-level and workflow-level concurrency are independent; you can use both, but they must not deadlock each other.
  • A queued job counts against the run duration, so a long queue can hit the workflow timeout.

Related guides

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