Reputation:
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?
Upvotes: 4
Views: 5179
Reputation: 1657
You can enable auto-merge on the PR using gh CLI:
gh pr merge <PR_NUMBER> --auto
This is not REST API but it's still from the command line. I hope this helps.
Upvotes: 2
Reputation: 1643
It is now possible to do it through the REST API:
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO \
-d '{"allow_auto_merge":true}'
See: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#update-a-repository
Upvotes: -6
Reputation: 41
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
}
}
Upvotes: 3
Reputation: 541
It seems that at the moment it's not possible to do it via Rest API, but you can use GraphQL API mutation enablePullRequestAutoMerge
instead.
Upvotes: 1