Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable auto-merge on a github pull request via the Rest API

I have permission, the repo allows it. I create a bunch of PRs using a cli tool and then I have to go open N tabs and double click the Enable Auto-Merge -> Confirm process for each one.

Does the API offer an issue/pr modify method to set this attribute automatically without resorting to the UI?


1 Answers

I solved it like this: Request POST to https://api.github.com/graphql to get pullRequestID value body:

query MyQuery {
    repository(name: "repo-example", owner: "org-example) {
        pullRequest(number: 49) {
                  id
              }
        } 
}

With pullRequest ID make a mutation: Request POST to https://api.github.com/graphql

mutation MyMutation {
    enablePullRequestAutoMerge(input: {pullRequestId: "$pullRequestID", mergeMethod: MERGE}) {
        clientMutationId
         }
}
like image 164
Jonathan Bezerra de Oliveira Avatar answered Oct 30 '25 11:10

Jonathan Bezerra de Oliveira