You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何阻止GitHub Actions指定Job在PR编辑事件时运行?

解决GitHub Actions中指定Job不响应PR编辑事件的问题

你的问题出在条件判断的字段路径错误,正确的字段应该是github.event.action,而非github.event.pull_request.action或github.event.pull_request.edited。

正确配置方式

保留工作流的触发配置不变(因为其他Job需要响应编辑事件),仅修改run_tests Job的if条件:

on:
  pull_request:
    types: [opened, synchronize, reopened, edited]

jobs:
  run_tests:
    name: Run Tests
    continue-on-error: false
    if: github.event.action != 'edited'
    # 此处添加Job的其他配置步骤

  # 其他需要响应编辑事件的Job配置...

原理说明

GitHub Actions的pull_request事件中,当前触发的操作类型(如opened、edited、synchronize)存储在github.event.action字段中,并非pull_request对象的子字段。之前的错误写法导致条件判断失效,修改字段路径后,即可实现:仅当PR操作不是edited时,才执行run_tests Job。

内容的提问来源于stack exchange,提问作者Probosckie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 04:01:07