Skip to content

Conversation

@ppkarwasz
Copy link
Contributor

This adds support for the auto_merge setting in GitHub repositories.

If auto_merge is true users can enable auto-merging of selected pull requests: those requests will be merged as soon as the PR has the required number of reviews and all required status checks passed.
See GitHub documentation for more details.

This adds support for the `auto_merge` setting in GitHub repositories.
If `auto_merge` is `true` users can enable auto-merging of selected pull requests: those requests will be merged as soon as the PR has the required number of reviews and all required status checks passed.
See [GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request) for more details.
@netomi
Copy link
Member

netomi commented Apr 13, 2025

When looking how the options are organized in the UI:

image

you see that options related to PRs are grouped slightly differently.

So we have the merge method (what we call enabled_merge_buttons) and then some other settings wrt auto merging, update and auto_merge.

Imho, we should have a pull_requests feature, that bundles all these options together, other than that the PR looks great.

Something that I would add as this easily leads to confusion is a link to the documentation of the auto merge feature: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request

One thing that is very important: auto merge does only make sense if you have a branch protection rule with at least 1 status check as the button will only be visible if the PR can not be merged right away.

The idea of this feature is that you normally have to wait some time till the checks complete and only then can you click the merge button. So you can already say: merge this PR if all checks pass.

@ppkarwasz
Copy link
Contributor Author

Imho, we should have a pull_requests feature, that bundles all these options together, other than that the PR looks great.

What about backward compatibility? If I modify the schema to accept:

github:
  pull_requests:
    enabled_merge_buttons:
      squash: true

the old configuration will not work.

@netomi
Copy link
Member

netomi commented Apr 13, 2025

sorry I was not clear, I am not asking you to change that right away but I was wondering how to best organize these options. Adding the auto_merge to enabled_merge_buttons is also not fully correct and probably confusing.

@ppkarwasz
Copy link
Contributor Author

So your are suggesting to have github.pull_requests.auto_merge?

@netomi
Copy link
Member

netomi commented Apr 13, 2025

tbh I am not sure right now. There exists github.del_branch_an_merge and the github.enabled_merge_buttons.
Now where to add allow_auto_merge?
Also we should support allow_branch_update which would be easy to add as well.

So when we would start from scratch I would add a github.pull_request container to add these things, but doing that would break a lot of .asf.yaml files.

@ppkarwasz
Copy link
Contributor Author

@Humbedooh, any ideas?

@netomi
Copy link
Member

netomi commented Apr 14, 2025

what about adding a pull_requests feature that bundles the following things:

  • del_branch_on_merge
  • allow_update_branch
  • allow_auto_merge

the del_branch_on_merge would need to be deprecated and old formats can still be read.

Edit: and at one point in the future when we feel motivated we can also migrate the existing enabled_merge_buttons to that pull_requests stuff.

@ppkarwasz
Copy link
Contributor Author

Sounds good to me!

@netomi
Copy link
Member

netomi commented Apr 14, 2025

updated the PR with the outlined refactoring.

The legacy setting github.del_branch_on_merge is still supported. Once github.pull_requests is also used, an exception is raised when the legacy setting is still used and not migrated.

so imho, this looks clean, wdyt @Humbedooh

@netomi netomi changed the title Add support for automatic PR merging Add support for automatic PR merging and branch updates Apr 14, 2025
@ppkarwasz
Copy link
Contributor Author

I removed the documentation of the initially proposed github.enabled_merge_buttons.auto_merge in f1611a6

@Humbedooh
Copy link
Member

LGTM, nice work.

@netomi netomi merged commit e90c573 into apache:main Apr 23, 2025
5 checks passed
@ppkarwasz ppkarwasz deleted the feat/auto_merge branch April 23, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants