GitHub Actions triggered on pull request does not lock "Merge" Button if fails
Asked Answered
M

1

6

For a python application, I have setup a GitHub action that runs pytest (and other tools) on each pull request to master.

When the workflow fails, I saw it in the "Check" tab on the pull request page, but I can merge my branch even if the GitHub action fails:

enter image description here

In my repository, settings -> branches, I created a new protection rules that matches my need, but I can't specify any status check.

All I want to do is to use my workflow to allow (or forbid) a Pull Request to be merged according to the workflow's output.

Any ideas?

Maggiore answered 14/5, 2021 at 20:30 Comment(2)
Are you an admin on the repo? There is a setting that allows admins to still merge if any checks fail - among other things.Metatarsal
Yes I am. I actually thought about that but to be sure I added a friend as a simple contributor and he was also able to merge. So it's not related I think.Maggiore
M
8

Ok so the right answer is pretty straightforward but it is not documented:

When creating a branch protection rule, you must check Require status checks to pass before merging (that's what I did), AND (that's what I did not) you MUST add a status check by searching it in the search bar.

If nothing appears, it's normal. You have to search the status check, it's the name of your job on your GitHub Action !

Maggiore answered 14/5, 2021 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.