Question 1 · Author and Manage Workflows
A company wants to prevent concurrent deployments to the production environment from the same branch. They want any new run to cancel the currently running one if it exists. Which concurrency configuration achieves this?
Show answer & explanation
Correct answer: B
- B. concurrency: group: deploy-prod-${{ github.ref }} cancel-in-progress: true
Option B is correct. Using ${{ github.ref }} in the group name scopes the concurrency group per branch, so simultaneous deployments from different branches don't interfere with each other. cancel-in-progress: true ensures the older run is cancelled when a new one starts for the same group. Option D is wrong because cancel-in-progress: false (the default) only queues the new run rather than cancelling the existing one — this prevents concurrent runs but doesn't cancel them. Option C is wrong because ${{ github.run_id }} is unique per run, meaning every run gets its own concurrency group and they never compete — the concurrency setting becomes entirely ineffective. Option A is wrong because cancel-in-progress is not a valid key directly under a job's concurrency field when it is expressed as a scalar string; the correct structure uses an object with group and cancel-in-progress keys. Additionally, placing it only at the job level without scoping to ${{ github.ref }} would conflict across branches.