Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nilsreichardt opened this issue Jul 1, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@nilsreichardt
Copy link

nilsreichardt commented Jul 1, 2021

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/automerge-action@v0.14.2
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/automerge-action@v0.14.2"
        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

@pascalgn
Copy link
Owner

pascalgn commented Sep 3, 2021

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? 😅

@matteovivona
Copy link

matteovivona commented Oct 22, 2021

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/automerge-action@v0.14.3"
         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

@pascalgn
Copy link
Owner

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 pascalgn added the bug Something isn't working label Nov 17, 2021
@matteovivona
Copy link

matteovivona commented Nov 17, 2021

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

@pascalgn
Copy link
Owner

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?

@matteovivona
Copy link

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

@jamesbhobbs
Copy link

This seems to be a dupe of #65

@pascalgn
Copy link
Owner

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 pascalgn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants