diff --git a/github-actions-helpers/Build.Github.cs b/github-actions-helpers/Build.Github.cs index fcd5faa681d..a25eb0b3ed7 100644 --- a/github-actions-helpers/Build.Github.cs +++ b/github-actions-helpers/Build.Github.cs @@ -206,93 +206,6 @@ await client.Issue.Comment.Create( } } - async Task PostCommentToPullRequest(int prNumber, string markdown) - { - Console.WriteLine("Posting comment to GitHub"); - - // post directly to GitHub as - var httpClient = new HttpClient(); - httpClient.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json"); - httpClient.DefaultRequestHeaders.Add("Authorization", $"token {GitHubToken}"); - httpClient.DefaultRequestHeaders.UserAgent.Add(new(new System.Net.Http.Headers.ProductHeaderValue("nuke-ci-client"))); - - var url = $"https://api.github.com/repos/{GitHubRepositoryOwner}/{GitHubRepositoryName}/issues/{prNumber}/comments"; - Console.WriteLine($"Sending request to '{url}'"); - - var result = await httpClient.PostAsJsonAsync(url, new { body = markdown }); - - if (result.IsSuccessStatusCode) - { - Console.WriteLine("Comment posted successfully"); - } - else - { - var response = await result.Content.ReadAsStringAsync(); - Console.WriteLine("Error: " + response); - result.EnsureSuccessStatusCode(); - } - } - - async Task HideCommentsInPullRequest(int prNumber, string prefix) - { - try - { - Console.WriteLine("Looking for comments to hide in GitHub"); - - var clientId = "nuke-ci-client"; - var productInformation = Octokit.GraphQL.ProductHeaderValue.Parse(clientId); - var connection = new Octokit.GraphQL.Connection(productInformation, GitHubToken); - - var query = new Octokit.GraphQL.Query() - .Repository(GitHubRepositoryName, GitHubRepositoryOwner) - .PullRequest(prNumber) - .Comments() - .AllPages() - .Select(issue => new { issue.Id, issue.Body, issue.IsMinimized, }); - - var issueComments = (await connection.Run(query)).ToList(); - - Console.WriteLine($"Found {issueComments} comments for PR {prNumber}"); - - var count = 0; - foreach (var issueComment in issueComments) - { - if (issueComment.IsMinimized || ! issueComment.Body.StartsWith(prefix)) - { - continue; - } - - try - { - var arg = new MinimizeCommentInput - { - Classifier = ReportedContentClassifiers.Outdated, - SubjectId = issueComment.Id, - ClientMutationId = clientId - }; - - var mutation = new Mutation() - .MinimizeComment(arg) - .Select(x => new { x.MinimizedComment.IsMinimized }); - - await connection.Run(mutation); - count++; - - } - catch (Exception ex) - { - Logger.Warning($"Error minimising comment with ID {issueComment.Id}: {ex}"); - } - } - - Console.WriteLine($"Minimised {count} comments for PR {prNumber}"); - } - catch (Exception ex) - { - Logger.Warning($"There was an error trying to minimise old comments with prefix '{prefix}': {ex}"); - } - } - Target AssignLabelsToPullRequest => _ => _ .Unlisted() .Requires(() => GitHubRepositoryName)