[英]Trigger CI when a commit is pushed and a PR is approved?
I used to have a GitHub Actions workflow configured like this:我曾经有一个 GitHub Actions 工作流配置如下:
name: CI
on: [push, pull_request]
I was interested in switching my trigger to a PR approval instead, so I changed it to:我有兴趣将触发器切换为 PR 批准,所以我将其更改为:
name: CI
on: [push, pull_request_review]
and in the job I added the following if
element:在工作中我添加了以下
if
元素:
myJob:
name: Name of my job
if: github.event_name == 'push' || github.event.review.state == 'approved'
runs-on: ubuntu-22.04
container: ...
However, the push trigger keeps working but the PR approval trigger does not.但是,推送触发器继续工作,但 PR 批准触发器不工作。
I've also tried to define my on:
setting in a more specific way, like this:我还尝试以更具体的方式定义我的
on:
设置,如下所示:
on:
pull_request_review:
types: [submitted]
push:
But it doesn't do the trick.但这并不能解决问题。 What else am I missing to make this work?
我还缺少什么来完成这项工作? I extracted all the above know-how from the documentation .
我从文档中提取了以上所有知识。
Argh, it was not a code issue, but a settings issue, If the repo is private: this has to be enabled: https://github.com/user/repo/settings/actions -> option Run workflows from fork pull requests (if the repository is under an organization, it has to be enabled first in the organization settings; after that, it can be enabled in the repository settings).啊,这不是代码问题,而是设置问题,如果 repo 是私有的:必须启用: https://github.com/user/repo/settings/actions -> 选项从 fork 拉取请求运行工作流(如果存储库在组织下,则必须先在组织设置中启用它;之后,它可以在存储库设置中启用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.