From 7d90f30d0908a1b79ab3ef5e6f06778aa4e87c1c Mon Sep 17 00:00:00 2001 From: Louis Fischer Date: Sat, 6 Jan 2024 22:43:31 -0600 Subject: [PATCH] AutoMerge Pull Request (#6) AutoMerge Pull Request enabled --- .../GitHubEndpointsPullRequestAliases.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Cake.GitHub.Endpoints/GitHubEndpointsPullRequestAliases.cs b/src/Cake.GitHub.Endpoints/GitHubEndpointsPullRequestAliases.cs index 903fb65..df4f35a 100644 --- a/src/Cake.GitHub.Endpoints/GitHubEndpointsPullRequestAliases.cs +++ b/src/Cake.GitHub.Endpoints/GitHubEndpointsPullRequestAliases.cs @@ -108,15 +108,16 @@ public static async Task GitHubPullRequestAutoMerge(this IGitHubEnd await context.HttpPostAsync(GraphQL.ApiUrl, settings => { settings.UseBearerAuthorization(context.GitHubToken) - .SetRequestBody($"mutation PullRequestAutoMerge {{ enablePullRequestAutoMerge(input: {{pullRequestId: \"{pr.NodeId}\", mergeMethod: {mergeMethod.ToString().ToUpperInvariant()}}}) {{ clientMutationId }}}}") - .SetContentType("application/json"); + .SetJsonRequestBody(new + { + query = @"mutation PullRequestAutoMerge($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod) { enablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId, mergeMethod: $mergeMethod }) { actor { login } clientMutationId pullRequest { id } }}", + variables = new { pullRequestId = pr.NodeId, mergeMethod = mergeMethod.ToString().ToUpperInvariant() } + }); }); - return pr; + return await GitHubPullRequest(context, number); } - //=> context.GitHubClient().PullRequest.Merge(context.Owner, context.RepoName, number, new MergePullRequest { MergeMethod = PullRequestMergeMethod.Squash, CommitTitle = title, CommitMessage = message }); - /// /// Get the pull request merge status. ///