automerge-action icon indicating copy to clipboard operation
automerge-action copied to clipboard

`automerge` merges pull request, even the checks are not passed (`PR is probably ready: mergeable_state: unstable`)

Open nilsreichardt opened this issue 4 years ago • 7 comments

Description

automerge merges sometime the pull requests, even if the checks not are completed.

From README.md

When using a personal access token (PAT) to work around the above limitation, note that when the user issuing the PAT is an administrator and branch restrictions do not include administrators, pull requests may be merged even if they are not mergeable for non-administrators (see #65). As you can see in the settings screenshot, I enabled "Include administrators" 🤔

It merges the pull request, if the required check (label-pr) is completed.

image

Logs

Run pascalgn/[email protected]
2021-07-01T14:41:33.965Z INFO  Event name: pull_request
2021-07-01T14:41:34.677Z INFO  Updating PR #414 ci(flutter): integration test only on `main`
2021-07-01T14:41:34.677Z INFO  No update done due to PR mergeable_state blocked
2021-07-01T14:41:34.678Z INFO  Merging PR #414 ci(flutter): integration test only on `main`
2021-07-01T14:41:34.678Z INFO  Current PR status: mergeable_state: blocked
2021-07-01T14:41:34.678Z INFO  Retrying after 5000 ms ... (1/6)
2021-07-01T14:41:40.016Z INFO  PR is probably ready: mergeable_state: unstable
2021-07-01T14:41:41.586Z INFO  PR successfully merged!

automerge file

name: automerge

on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  check_suite:
    types:
      - completed
  status: {}

jobs:
  automerge:
    runs-on: ubuntu-latest
    if: |
      contains(github.event.pull_request.labels.*.name, 'auto-merge') &&
      github.event.pull_request.draft == false
    steps:
      - name: automerge
        uses: "pascalgn/[email protected]"
        env:
          # We need to use a personal access token (it's the Nils access token),
          # because the GitHub Actions are not able to merge a PR, when protect
          # our branch (Restrict who can push to matching branches). 
          GITHUB_TOKEN: "${{ secrets.AUTOMERGE_TOKEN }}"
          MERGE_LABELS: "auto-merge"
          UPDATE_LABELS: "auto-merge"
          MERGE_COMMIT_MESSAGE: "pull-request-title-and-description"
          MERGE_METHOD: "squash"

Protected Branch Settings

image

nilsreichardt avatar Jul 01 '21 14:07 nilsreichardt

From the README:

When the pull request is ready, it will automatically be merged. The action will only wait for status checks that are marked as required in the branch protection rules

Does this help already? 😅

pascalgn avatar Sep 03 '21 17:09 pascalgn

I've the same problem. automerge action rebase PRs even if some mandatory checks fail

My config:

name: Automerge 
 on:
   check_suite:
     types:
       - completed
   status: {}
 jobs:
   automerge:
     runs-on: ubuntu-latest
     steps:
       - name: automerge
         uses: "pascalgn/[email protected]"
         env:
           GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
           MERGE_LABELS: "autoapproved, dependencies, !in progress"
           MERGE_METHOD: "merge"
           MERGE_RETRIES: "6"
           MERGE_REQUIRED_APPROVALS: "1"
           UPDATE_LABELS: "automerged"
           UPDATE_METHOD: "rebase"

Branch rules Screenshot 2021-10-22 at 09 17 33

Checks

Screenshot 2021-10-22 at 09 17 57

matteovivona avatar Oct 22 '21 07:10 matteovivona

Somehow those 2 screenshots don't match. If an action is marked as required in the branch protection rules, it should also be shown with a "Required" text in the status overview, like here:

image

pascalgn avatar Nov 17 '21 17:11 pascalgn

I think once merged that info disappears. As you can see from this screenshot there are workflows required

Screenshot 2021-11-17 at 21 44 24

matteovivona avatar Nov 17 '21 20:11 matteovivona

OK, then maybe the issue could be that the user "hospitalrunbot" you're using to run automerge-action maybe has admin rights on the repository and thus may bypass failed required checks?

pascalgn avatar Nov 17 '21 20:11 pascalgn

OK, then maybe the issue could be that the user "hospitalrunbot" you're using to run automerge-action maybe has admin rights on the repository and thus may bypass failed required checks?

Good point. I'll see if it's due to that

matteovivona avatar Nov 17 '21 21:11 matteovivona

This seems to be a dupe of #65

jamesbhobbs avatar Dec 23 '21 19:12 jamesbhobbs

I think this is not yet fixed, or at least it's not clear what the cause for the problem is. However, it's a long time since there was some activity in this issue, so I will close it for now. If you have any new information or need any help, feel free to reopen this issue!

pascalgn avatar Oct 17 '22 17:10 pascalgn