mergeable icon indicating copy to clipboard operation
mergeable copied to clipboard

Is that possible to limit auto merge to issues with certain labels?

Open LeoQuote opened this issue 4 years ago • 5 comments

I'm trying to setup mergeable to merge pr when CI passed and labeled "lgtm" , I tried this https://github.com/LeoQuote/test-repo/blob/master/.github/mergeable.yml but not working as I expected. The pr https://github.com/LeoQuote/test-repo/pull/2 was merged right after CI passed, totally ignored the validate I configured.

Expected: auto merge only merge pr labeled lgtm

Actual: auto merge merges every pr.

mergeable config:

version: 2
mergeable:
  - when: pull_request.*, pull_request_review.*, status.*, check_suite.*
    name: "Automatically merge pull requests once it passes all checks"
    validate:
      - do: label
        must_include:
          regex: 'lgtm|approved|goodtogo'
          message: 'We need lgtm tag to auto merge'
    pass:
      - do: merge
        merge_method: "squash"

I know this can be done by setting another rule enforcing lgtm label and set mergeable check as a must. But I want it this way as it does not require every single pr labeled lgtm

LeoQuote avatar Jan 14 '21 04:01 LeoQuote

@LeoQuote Hey, thanks for bringing this to our attention. We will look into this.

The merge action currently as it is implemented does rely on the mergeable checks being required for the validators to be enforced.

@shine2lay From a quick glance, I believe the scope of work is:

  • Amending EventAware.getPayload to support the events'status' and 'check_suite' such that the correct PR is returned. This code is already in the Merge` action.
  • Refactor the Merge action to use EventAware.getPayload instead.
  • Update supportedEvents in the validators to include status.success and check_suite

Thoughts?

jusx avatar Jan 14 '21 08:01 jusx

Related to #431

jusx avatar Jan 14 '21 08:01 jusx

I second this feature request. Our config checks if an auto merge label exists and we have mergeable set as a required check. Our issue is that the labels validator won't run on check_suite and status events as you mentioned nor will it run on label created events. Therefore, our team finds the auto merge functionality buggy because we only trigger auto merge if we get a pull_request.edited or pull_request_review.submitted event!!

jaisal1024 avatar Jun 10 '21 17:06 jaisal1024

@jaisal1024 thanks for the feedback, I agree that current feature is not ideal. I am very busy to take on this task for now, If you want to create a PR for this feature, I'll make sure to get that reviewed and merged in ASAP. If not I'll try to pick this up when I have some free time.

shine2lay avatar Jun 10 '21 18:06 shine2lay

Hey id love to give it a shot, just need some bandwidth from my team lead

jaisal1024 avatar Jun 10 '21 19:06 jaisal1024