Repository: noqdev/iambic
Issue: GitHub App does not work if merge commits are disabled

**Describe the bug**

The GitHub app fails to merge during `iambic apply` if linear history is required, and merge commits are turned off.

```
 File "/app/iambic/plugins/v0_1_0/github/github.py", line 416, in handle_iambic_git_apply
   maybe_merge(templates_repo, pull_number, merge_sha)
 File "/app/iambic/plugins/v0_1_0/github/github.py", line 451, in maybe_merge
   raise RuntimeError(
RuntimeError: Fail to merge PR. Target sha is a97a9d35b285b016baea4d796b768e905ffc0192. last_known_trace_back is Traceback (most recent call last):
 File "/app/iambic/plugins/v0_1_0/github/github.py", line 444, in maybe_merge
   merge_status = pull_request.merge(sha=merge_sha)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.11/site-packages/github/PullRequest.py", line 883, in merge
   headers, data = self._requester.requestJsonAndCheck(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 353, in requestJsonAndCheck
   return self.__check(
          ^^^^^^^^^^^^^
 File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 378, in __check
   raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 405 {"message": "Merge commits are not allowed on this repository.", "documentation_url": "https://docs.github.com/rest/reference/pulls#merge-a-pull-request"}
```

**To Reproduce**

**Repo General Setting:**

![image](https://github.com/noqdev/iambic/assets/613305/86270579-d8f7-4446-b886-fdb9d4daa111)

**Branch Protection Settting:**

![image](https://github.com/noqdev/iambic/assets/613305/6af222c0-c9fc-4558-82bd-3281f5fbc9ab)

**Expected behavior**
The GitHub app should be able to merge using the allowed settings of the repository.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22] 0.10.1

**Additional context**
Add any other context about the problem here.

**Community Engagement**
Your vote counts! Please support this bug report by adding a 👍 reaction to the original issue, which will aid the community and maintainers in addressing this problem.

Please refrain from adding "+1" or "me too" comments, as these create unnecessary noise for issue followers and do not help in prioritizing the issue. If you wish to contribute to solving this issue or have submitted a pull request, please leave a comment.


Changed files:
iambic/plugins/v0_1_0/github/github.py, test/plugins/v0_1_0/github/test_github.py

diff --git a/iambic/plugins/v0_1_0/github/github.py b/iambic/plugins/v0_1_0/github/github.py
index 886c48c3..52c6a3e8 100644
--- a/iambic/plugins/v0_1_0/github/github.py
+++ b/iambic/plugins/v0_1_0/github/github.py
@@ -447,13 +447,24 @@ def maybe_merge(
 ):
     """Attempts to merge the PR at specific sha, this function will retry a few times because
     desired sha maybe not available yet"""
+
+    merge_method = None
+    if templates_repo.allow_merge_commit:
+        merge_method = "merge"
+    elif templates_repo.allow_squash_merge:
+        merge_method = "squash"
+    elif templates_repo.allow_rebase_merge:
+        merge_method = "rebase"
+    else:
+        merge_method = "NOT_SUPPORTED"
+
     attempts = 0
     merge_status = None
     last_known_traceback = None
     while attempts < max_attempts:
         pull_request = templates_repo.get_pull(pull_number)
         try:
-            merge_status = pull_request.merge(sha=merge_sha)
+            merge_status = pull_request.merge(sha=merge_sha, merge_method=merge_method)
             break
         except github.GithubException:
             last_known_traceback = traceback.format_exc()
diff --git a/test/plugins/v0_1_0/github/test_github.py b/test/plugins/v0_1_0/github/test_github.py
index f8460de5..80263e23 100644
--- a/test/plugins/v0_1_0/github/test_github.py
+++ b/test/plugins/v0_1_0/github/test_github.py
@@ -492,7 +492,7 @@ def test_issue_comment_with_clean_mergeable_state_with_additional_commits(
     )
 
     # verify we are merging with the latest local repo sha
-    mock_pull_request.merge.assert_called_with(sha=post_sha)
+    mock_pull_request.merge.assert_called_with(sha=post_sha, merge_method="merge")
 
 
 def test_run_handler():