Refine concurrency group logic in PR build workflow

Updated the concurrency group strategy in pr-build.yml to better handle different event types. Now, pull_request_target uses the PR number, and issue_comment only uses the PR number if the comment is a /build command, otherwise defaults to run_id. This prevents unnecessary cancellation of builds triggered by unrelated comments.
This commit is contained in:
手瓜一十雪 2026-01-03 15:09:33 +08:00
parent 018e8aa4f0
commit 20f6101f95

View File

@ -41,8 +41,14 @@ permissions:
# 并发控制
# =============================================================================
# 同一 PR 的多次构建会取消之前未完成的构建,避免资源浪费
# 注意:只有在 should_build=true 时才会进入实际构建流程,
# issue_comment 事件如果不是 /build 命令,会在 check-build 阶段快速退出,
# 不会取消正在进行的构建(因为 cancel-in-progress 只影响同 group 的后续任务)
concurrency:
group: pr-build-${{ github.event.pull_request.number || github.event.issue.number || github.run_id }}
# 使用不同的 group 策略:
# - pull_request_target: 使用 PR 号
# - issue_comment: 只有确认是 /build 命令时才使用 PR 号,否则使用 run_id不冲突
group: pr-build-${{ github.event_name == 'pull_request_target' && github.event.pull_request.number || github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/build') && github.event.issue.number || github.run_id }}
cancel-in-progress: true
# =============================================================================