Skip to content

Commit a0a618d

Browse files
ci: cancel stale pull request workflow runs
The CI workflow groups runs by commit hash, so every push to a pull request starts a separate workflow run. Group pull request runs by pull request number and cancel runs superseded by a newer push, while keeping push events grouped by commit hash for the skip-if-redundant behavior. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
1 parent a97fcc3 commit a0a618d

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

.github/workflows/main.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ on: [push, pull_request]
55
env:
66
DEVELOPER: 1
77

8-
# If more than one workflow run is triggered for the very same commit hash
9-
# (which happens when multiple branches pointing to the same commit), only
10-
# the first one is allowed to run, the second will be kept in the "queued"
11-
# state. This allows a successful completion of the first run to be reused
12-
# in the second run via the `skip-if-redundant` logic in the `config` job.
8+
# For pull requests, only the latest workflow run is allowed to proceed.
9+
# Older runs are canceled when a new revision is pushed.
1310
#
14-
# The only caveat is that if a workflow run is triggered for the same commit
15-
# hash that another run is already being held, that latter run will be
16-
# canceled. For more details about the `concurrency` attribute, see:
11+
# For pushes, if more than one workflow run is triggered for the very same
12+
# commit hash (which happens when multiple branches point to the same commit),
13+
# only the first one is allowed to run. This allows a successful completion of
14+
# the first run to be reused in the second run via the `skip-if-redundant`
15+
# logic in the `config` job.
16+
#
17+
# For more details about the `concurrency` attribute, see:
1718
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
1819
concurrency:
19-
group: ${{ github.sha }}
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
21+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2022

2123
jobs:
2224
ci-config:

0 commit comments

Comments
 (0)