]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ci: cancel stale pull request workflow runs
authorHarald Nordgren <haraldnordgren@gmail.com>
Fri, 31 Jul 2026 10:10:41 +0000 (10:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Jul 2026 16:46:07 +0000 (09:46 -0700)
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>
.github/workflows/main.yml

index cf341d74dbff21e92e70366d64cd5de23191936d..6b56c36996950f2d2325cc45c13fea09f92529d0 100644 (file)
@@ -5,18 +5,20 @@ on: [push, pull_request]
 env:
   DEVELOPER: 1
 
-# If more than one workflow run is triggered for the very same commit hash
-# (which happens when multiple branches pointing to the same commit), only
-# the first one is allowed to run, the second will be kept in the "queued"
-# state. This allows a successful completion of the first run to be reused
-# in the second run via the `skip-if-redundant` logic in the `config` job.
+# For pull requests, only the latest workflow run is allowed to proceed.
+# Older runs are canceled when a new revision is pushed.
 #
-# The only caveat is that if a workflow run is triggered for the same commit
-# hash that another run is already being held, that latter run will be
-# canceled. For more details about the `concurrency` attribute, see:
+# For pushes, if more than one workflow run is triggered for the very same
+# commit hash (which happens when multiple branches point to the same commit),
+# only the first one is allowed to run. This allows a successful completion of
+# the first run to be reused in the second run via the `skip-if-redundant`
+# logic in the `config` job.
+#
+# For more details about the `concurrency` attribute, see:
 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
 concurrency:
-  group: ${{ github.sha }}
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
 
 jobs:
   ci-config: