如果用户批准审核,则通过 Github 操作合并 PR
Merge PR by Github action if review was approved by a user
是否可以配置 Github 操作工作流以合并拉取请求,如果它被其中一位用户批准(使用 approve
关键字提交审查)(静态固定列表,可以编写在工作流配置文件中)?我试图在文档中找到它:https://help.github.com/en/articles/workflow-syntax-for-github-actions#on
- 我想我可以使用 on: [pull_request_review]
触发器来执行操作,但文档没有提到如何访问操作中的事件有效负载 yaml
文件,我需要从该有效负载中提取审阅者登录信息。
workflow/event.json
: The POST
payload of the webhook event that triggered the workflow. GitHub rewrites this each time an action executes to isolate file content between actions. Use the GITHUB_EVENT_PATH
environment variable to access this file.
因此下一步将弄清楚如何解析 JSON 文件并提取一些数据供 later 步骤使用。为此,查看 GitHub's setup-dotnet
action might prove useful. In line 62 of installer.ts
, they call a function called core.exportVariable
, which as you can see here,会导致 ##[set-env name=NAME;]value
打印在操作的输出中。我亲自验证了这会导致名为 NAME
的环境变量自动出现在同一工作流作业的后续步骤中。
现在,我还不知道您是否可以简单地在 GitHub 工作流程的 run
步骤中执行 echo "##[set-env name=NAME;]$VALUE"
并使其工作;您可能必须在 Typescript 中编写自定义操作才能访问 core.exportVariable
。但是,一旦您解析了 JSON,这将是将该信息传递给您工作中后续步骤的一种方式。
除了 rmunn's ,您可能还想保护您的分支:
GitHub Actions: Prevent GitHub Actions from approving pull requests (2022, 14th Jan.)
We have introduced a new policy setting that controls whether GitHub Actions can approve pull requests.
This protects against a user using Actions to satisfy the "Required approvals" branch protection requirement and merging a change that was not reviewed by another user.
To prevent breaking existing workflows, Allow GitHub Actions reviews to count towards required approval
is enabled by default.
However, an organization admin can disable it under the organization's Actions settings.
这样一来,您就可以确定批准是由 用户 独家完成的,而不是由其他操作完成的。
是否可以配置 Github 操作工作流以合并拉取请求,如果它被其中一位用户批准(使用 approve
关键字提交审查)(静态固定列表,可以编写在工作流配置文件中)?我试图在文档中找到它:https://help.github.com/en/articles/workflow-syntax-for-github-actions#on
- 我想我可以使用 on: [pull_request_review]
触发器来执行操作,但文档没有提到如何访问操作中的事件有效负载 yaml
文件,我需要从该有效负载中提取审阅者登录信息。
workflow/event.json
: ThePOST
payload of the webhook event that triggered the workflow. GitHub rewrites this each time an action executes to isolate file content between actions. Use theGITHUB_EVENT_PATH
environment variable to access this file.
因此下一步将弄清楚如何解析 JSON 文件并提取一些数据供 later 步骤使用。为此,查看 GitHub's setup-dotnet
action might prove useful. In line 62 of installer.ts
, they call a function called core.exportVariable
, which as you can see here,会导致 ##[set-env name=NAME;]value
打印在操作的输出中。我亲自验证了这会导致名为 NAME
的环境变量自动出现在同一工作流作业的后续步骤中。
现在,我还不知道您是否可以简单地在 GitHub 工作流程的 run
步骤中执行 echo "##[set-env name=NAME;]$VALUE"
并使其工作;您可能必须在 Typescript 中编写自定义操作才能访问 core.exportVariable
。但是,一旦您解析了 JSON,这将是将该信息传递给您工作中后续步骤的一种方式。
除了 rmunn's
GitHub Actions: Prevent GitHub Actions from approving pull requests (2022, 14th Jan.)
We have introduced a new policy setting that controls whether GitHub Actions can approve pull requests.
This protects against a user using Actions to satisfy the "Required approvals" branch protection requirement and merging a change that was not reviewed by another user.To prevent breaking existing workflows,
Allow GitHub Actions reviews to count towards required approval
is enabled by default.
However, an organization admin can disable it under the organization's Actions settings.
这样一来,您就可以确定批准是由 用户 独家完成的,而不是由其他操作完成的。