diff --git a/.github/workflows/pr-auto-review.yml b/.github/workflows/pr-auto-review.yml index 7dc5a780..ab549d96 100644 --- a/.github/workflows/pr-auto-review.yml +++ b/.github/workflows/pr-auto-review.yml @@ -44,24 +44,28 @@ on: permissions: {} -# Deduplicate ONLY pull_request events which have a direct PR context (issue #1126). -# On GitHub Free (20 concurrent jobs, org-wide), avoid race conditions when multiple -# PRs share a commit: -# • pull_request / pull_request_review — have github.event.pull_request.number; -# safe to collapse per PR and cancel in progress. -# • check_suite / workflow_run — only have pull_requests[] array; if multiple PRs -# share the commit, pull_requests[0] is indeterminate and causes the first PR's -# events to cancel the second PR's events. Use unique per-run groups instead. -# A trigger with no associated PR (fork / no PR) also falls back to unique-per-run -# so unrelated workflow runs never interfere. +# Deduplicate ONLY the default-branch-context triggers (issue #1126). On GitHub +# Free (20 concurrent jobs, org-wide) this stub fanned out per trigger. Its runs +# split by context: +# • check_suite / workflow_run — head_branch=main, the check does NOT attach to +# the PR head, so superseding an in-flight run is SAFE. Both events collapse +# onto one group per PR (`…-pr-`) with cancel-in-progress: true. +# • pull_request / pull_request_review — run on the PR head; a cancelled run +# would leave a cancelled `pr-auto-review / check-and-dispatch` check on the +# head. They get a unique-per-run group and never cancel — note this differs +# from the previous per-PR group + cancel-in-progress: true behaviour. +# A default-branch trigger with no associated PR (fork / no PR) also falls back to +# the unique-per-run group so unrelated PRs never collapse into one group. concurrency: group: >- ${{ - (github.event_name == 'pull_request' && format('pr-auto-review-ready-check-pr-{0}', github.event.pull_request.number)) - || (github.event_name == 'pull_request_review' && format('pr-auto-review-ready-check-pr-{0}', github.event.pull_request.number)) + (github.event_name == 'check_suite' && github.event.check_suite.pull_requests[0].number) + && format('pr-auto-review-ready-check-pr-{0}', github.event.check_suite.pull_requests[0].number) + || (github.event_name == 'workflow_run' && github.event.workflow_run.pull_requests[0].number) + && format('pr-auto-review-ready-check-pr-{0}', github.event.workflow_run.pull_requests[0].number) || format('pr-auto-review-ready-check-unique-{0}', github.run_id) }} - cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_review' }} + cancel-in-progress: ${{ github.event_name == 'check_suite' || github.event_name == 'workflow_run' }} jobs: pr-auto-review: