Skip to content

Commit 83476ee

Browse files
committed
Ensure older workflow runs for a pull-request are cancelled
The new `concurrency` setting can be used to ensure only a single workflow run or job is in progress. When used in combination with the `cancel-in-progress` setting, incomplete workflow runs can be cancelled automatically to prevent running workflows unnecessarily.
1 parent 35b0075 commit 83476ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ on:
66
- "master"
77
pull_request:
88

9+
# Cancel previous PR builds.
10+
concurrency:
11+
# Cancel all workflow runs except latest within a concurrency group. This is achieved by defining a concurrency group for the PR.
12+
# Non-PR builds have singleton concurrency groups.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
14+
cancel-in-progress: true
15+
916
jobs:
1017
checks:
1118
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)