如何阻止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
相关产品推荐
相关产品推荐

