如果测试失败github操作如何拒绝拉取请求 [英] how to reject a pull request if tests are failed github actions

查看:66
本文介绍了如果测试失败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

这篇关于如果测试失败github操作如何拒绝拉取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆