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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Harald Nordgren committed Jul 31, 2026 at 10:10 UTC c6b106fd8cfa13090d9a4b7417d01958ca6d37f1
1 file changed +11 -9
.github/workflows/main.yml
+11 -9
@@ -5,18 +5,20 @@ on: [push, pull_request]
5 env:
6 DEVELOPER: 1
7
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.
10 #
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:
18 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
19 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' }}
22
23 jobs:
24 ci-config: