简体   繁体   English

推送提交并批准 PR 时触发 CI?

[英]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.

相关问题 Azure Devops 构建管道:当 PR 没有附加任何工作项时,CI 触发器无法在 PR 合并到分支 - Azure Devops build pipeline: CI triggers not working on PR merge to a branch when there is no work item is attached with the PR 使用 CI_COMMIT_MESSAGE 时管道不运行 - Pipeline does not run when using CI_COMMIT_MESSAGE Azure Devops 管道在 PR 完成时触发 - Azure Devops pipelines to trigger on PR complete 当 gitlab CI/CD 触发时,如何通过 git 而不是从预定义的变量获取提交标签 - How to get the commit TAGS, via git and not from predefined vars, when gitlab CI/CD triggers Azure DevOps 触发仅针对特定 PR 的拉取请求 - Azure DevOps trigger pull request for only specific PR's Twilio 即使匹配已批准的模板,whatsapp 消息也会失败 - Twilio whatsapp message fails even when matches the approved template 未能触发构建:无法读取提交 - Failed to trigger build: Couldn't read commit 从预定的 lambda 触发 AWS codepipeline/codebuild 并阻止提交触发器 - Triggering AWS codepipeline/codebuild from a scheduled lambda and blocking commit trigger AWS Amplify - 我可以推送代码提交以启动 CI/CD 管道并构建新的后端资源吗? - AWS Amplify - Can I Push To Code Commit To Start The CI/CD Pipeline & Build The New Backend Resources? 在 GitHub Actions 中将草稿 PR 转换为可供审核的 PR 时,如何删除以前的工作流运行? - How can I remove previous workflow runs when converting a draft PR to a ready-for-review PR in GitHub Actions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM