public async Task UpdateBranch(string owner, string repo, string branch) { var defaultBranch = (await repoConfigManager.GetConfig(owner, repo)).DefaultBranch; if (branch == null) { throw new Exception($"Could not update branch for {owner}/{repo}, branch unknown"); } if (defaultBranch == null) { throw new Exception($"Could not update branch for {owner}/{repo}, head branch unknown"); } var payload = new UpdateBranchPayload() { CommitMessage = $"Merge branch {defaultBranch} into {branch}", Base = branch, Head = defaultBranch, }; string uri = $"/repos/{owner}/{repo}/merges"; logger.WithExtraData(new { owner, repo, branch, defaultBranch, uri }).Information($"Making github update branch request"); var response = await githubHttpClient.Post(uri, payload); try { response.EnsureSuccessStatusCode(); } catch (HttpRequestException e) { logger.WithExtraData(new { owner, repo, branch, uri }).Warning(e, $"Failed updating branch"); throw e; } }
private async Task GithubRequest(string owner, string repo, int prId, string prettyComment) { var url = $"/repos/{owner}/{repo}/issues/{prId}/comments"; var response = await githubHttpClient.Post(url, new CreateCommentPayload { Body = prettyComment }); response.EnsureSuccessStatusCode(); }
public async Task UpdateStatusCheck(string owner, string repo, string shaOrBranch, string statusCheck, string state = "success") { var payload = new UpdateStatusCheckPayload() { State = state, Context = statusCheck, Description = CommentsConsts.MiroMergeCheckDescription, }; var uri = $"/repos/{owner}/{repo}/statuses/{shaOrBranch}"; logger.WithExtraData(new { owner, repo, shaOrBranch, uri, payload }).Information($"Making github update status check request"); var response = await githubHttpClient.Post(uri, payload); response.EnsureSuccessStatusCode(); }