Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-reject a pull request if tests are failing (Github actions)

Tags:

I am doing npm test when pull requests are raised using Github actions.

  • Now if tests fail,
  • I would like to add a message,
  • Or at least, reject the PR using actions.

How can I do this?

like image 786
Janier Avatar asked Nov 01 '19 05:11

Janier


People also ask

How do you reject a pull request?

You can continue to comment on a declined pull request, but new changes pushed to the branch no longer update the pull request. To decline a pull request, select the More options ( ) button and select Decline in the dropdown menu. After the pull request is declined, the comments and tasks are preserved.

Can a pull request be reverted?

While you can't undo a pull request, you can revert the merged commit from a pull request if necessary. Bitbucket takes two steps to revert a pull request: 1) Bitbucket creates a new branch with one commit that reverses the merged commit. 2) Bitbucket creates a new pull request for the branch and commit.

How do I reject a pull request from GitHub?

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.

What happens when I create a pull request from local changes?

The local changes will be automatically committed to a new branch and a pull request created. Create Pull Request action will: Check for repository changes in the Actions workspace. This includes:

How do I automatically approve dependabot pull requests?

If you want to automatically approve Dependabot pull requests, you can use the GitHub CLI in a workflow: If you want to auto-merge your pull requests, you can use GitHub's auto-merge functionality. This enables the pull request to be merged when all required tests and approvals are successfully met.

How does the create-pull-request action work?

The create-pull-request action is designed to be used in conjunction with other steps that modify or add files to your repository. The local changes will be automatically committed to a new branch and a pull request created. Create Pull Request action will: Check for repository changes in the Actions workspace. This includes:


1 Answers

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. require 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

like image 151
peterevans Avatar answered Sep 21 '22 16:09

peterevans