Prevent redundant runs and potential concurrency collisions with Merge Queue

When a PR enters the merge queue, GitHub triggers both a 'merge_group'
and a 'push' event. These events might share the same concurrency key
as they both reference the temporary 'gh-readonly-queue/' branch.

This creates a race condition where the redundant 'push' job could
incorrectly cancel the official 'merge_group' run. This commit adds
an explicit filter to ignore 'push' events on queue branches,
ensuring CI stability and saving runner minutes.
This commit is contained in:
vlakoff 2026-04-30 01:36:55 +02:00
parent e3eff7061f
commit 8d1ead4eef
No known key found for this signature in database
GPG key ID: D01DA5A5B698E332
2 changed files with 19 additions and 4 deletions

View file

@ -24,6 +24,9 @@ concurrency:
jobs:
build:
uses: docker/github-builder/.github/workflows/build.yml@v1
# Exclude 'push' events from the Merge Queue to avoid a race condition where
# the 'push' event might cancel the 'merge_group' event via the concurrency group.
if: (!(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/')))
permissions:
contents: read
packages: write

View file

@ -19,8 +19,14 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
# Prevent tags and in-repo PRs from triggering this workflow more than once for a commit
if: github.ref_type != 'tag' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
# Prevent tags and in-repo PRs from triggering this workflow more than once for a commit.
# We also exclude 'push' events from the Merge Queue (gh-readonly-queue/) because they
# trigger alongside the 'merge_group' event. Without this, a race condition in the
# concurrency group could cause the 'push' event to cancel the 'merge_group' event.
if: >-
github.ref_type != 'tag' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) &&
(!(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/')))
strategy:
fail-fast: false
@ -154,8 +160,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
# Prevent tags and in-repo PRs from triggering this workflow more than once for a commit
if: github.ref_type != 'tag' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
# Prevent tags and in-repo PRs from triggering this workflow more than once for a commit.
# We also exclude 'push' events from the Merge Queue (gh-readonly-queue/) because they
# trigger alongside the 'merge_group' event. Without this, a race condition in the
# concurrency group could cause the 'push' event to cancel the 'merge_group' event.
if: >-
github.ref_type != 'tag' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) &&
(!(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/')))
steps:
- name: Checkout source