fix(ci): prevent AI review self-cancellation with smart concurrency

Root cause: When the bot posts a review comment, GitHub fires an
issue_comment event that joins the same concurrency group and cancels
the in-progress run BEFORE job `if` conditions are evaluated.

Solution: Non-actionable triggers (bot comments, comments without
/review) get a unique per-run group via format('skip-{0}', github.run_id),
while legitimate triggers share the PR-based group for proper
cancellation of outdated reviews.
This commit is contained in:
kaitranntt
2026-01-13 16:03:02 -05:00
parent 865870ba4c
commit 25d31ce432
+19 -3
View File
@@ -24,10 +24,26 @@ on:
required: true required: true
type: string type: string
# Simple concurrency: one review per PR at a time # Smart concurrency: Prevents self-cancellation when bot posts review comment
# With track_progress disabled, no bot comments are posted during review #
# Problem: When the bot posts a review comment, GitHub fires an issue_comment event.
# This new workflow run joins the same concurrency group and cancels the in-progress
# run BEFORE job `if` conditions are evaluated - causing "operation was canceled" error.
#
# Solution: Non-actionable triggers (bot comments, comments without /review) get a
# unique per-run group, while legitimate triggers share the PR-based group for proper
# cancellation of outdated reviews.
concurrency: concurrency:
group: ai-review-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }} group: >-
ai-review-${{
github.event_name == 'issue_comment' && (
github.event.comment.user.type == 'Bot' ||
!contains(github.event.comment.body, '/review')
) && format('skip-{0}', github.run_id) ||
github.event.pull_request.number ||
github.event.issue.number ||
github.event.inputs.pr_number
}}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs: