From 8d1ead4eef6c716f85231535e9be565d85a16e09 Mon Sep 17 00:00:00 2001 From: vlakoff <544424+vlakoff@users.noreply.github.com> Date: Thu, 30 Apr 2026 01:36:55 +0200 Subject: [PATCH] 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. --- .github/workflows/docker.yml | 3 +++ .github/workflows/oxipng.yml | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 34ca89a6..981fc7f8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 diff --git a/.github/workflows/oxipng.yml b/.github/workflows/oxipng.yml index 9a7d669e..e8dc31df 100644 --- a/.github/workflows/oxipng.yml +++ b/.github/workflows/oxipng.yml @@ -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