如果测试失败github操作如何拒绝拉取请求
使用Github操作引发拉取请求时,我正在进行npm测试.现在,如果测试失败,我想添加一条消息或至少使用操作拒绝PR.我该怎么办?
I am doing npm test when pull requests are raised using Github actions . Now if tests fails , I would like to add a message or at least reject the PR using actions.. How can i do it?
我假设您有一个运行 npm test
的 on:pull_request
工作流程.这将在拉取请求上自动创建GitHub Check,如果测试失败,该请求将失败.除非测试通过,否则拒绝"拉取请求的最佳方法是防止其被合并.为此,您可以打开存储库中的合并之前要求状态检查通过",然后根据需要选择工作流程.
I assume you have an on: pull_request
workflow that runs npm test
. This should automatically create a GitHub Check on the pull request that will fail if your tests fail. The best way to "reject" the pull request is to prevent it from being merged unless the tests pass. You can do this by turning on a setting in your repository to "Require status checks to pass before merging," and selecting your workflow as required.
您可以在存储库的设置> 分支下找到此设置.
You can find this setting under your repository's Settings > Branches.
文档中有关于这些设置的更多详细信息. https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks
There are further details about these settings in the documentation. https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks