public static async Task <EmbedBuilder> MakeGithubEmbed(GithubModel model, ICommandContext context) { EmbedBuilder emb = new EmbedBuilder() { Color = Color.Teal, Title = model.ProjectName, Url = GithubParser.ProjectLink, ThumbnailUrl = "https://i.imgur.com/ASk5DlY.png" }; emb.WithDescription(model.ProjectDescription); emb.AddField("Commits", model.Commits, true); emb.AddField("Stars", model.Stars, true); emb.AddField("Watchers", model.Watchers, true); emb.AddField("Author", model.AuthorName, true); emb.AddField("Found a bug,want to contribute or request a feature?", model.IssueLink); EmbedFooterBuilder footer = await EmbedBuilderFunctions.AddFooter(context); footer.Text += " - Powered by Github"; emb.WithFooter(footer); return(emb); }
private void TriggerTeamCityBuild(GithubModel model) { var branch = model.Ref.Replace("refs/heads/", ""); var buildConfId = ""; var branchName = string.Empty; if (branch.StartsWith("feature") || branch.StartsWith("bugfix")) { buildConfId = "SkyeEditor_Features"; branchName = branch.Substring(branch.LastIndexOf('/') + 1); } if (branch.StartsWith("release")) { //todo this seems not to work check http://ci.innoveo.com/viewType.html?buildTypeId=SkyeEditor_Release&branch_SkyeEditor_Releases=skye-editor-4.23.0&tab=buildTypeStatusDiv buildConfId = "SkyeEditor_Release"; //LAURENT: TODO move to settings var releaseBranchNamePrefix = "/skye-editor-"; branchName = branch.Substring(branch.LastIndexOf(releaseBranchNamePrefix, StringComparison.Ordinal) + releaseBranchNamePrefix.Length); } if (string.IsNullOrWhiteSpace(branchName)) { return; } StartBuildAsync(buildConfId, branchName); }
public async Task CheckForUpdates(bool force) { if (Model.Status == UpdateStatus.Checking) { Logger.Warning("Cannot check for new updates because the status says it's already checking for one"); return; } if (!force && Model.LastCheckInMinutes < 30) { Logger.Warning("Cannot check for new updates because the last check was less than 30m"); return; } Logger.Info("Checking for updates..."); Model.LastCheck = DateTime.Now; Model.Status = UpdateStatus.Checking; JsonDownloader jsonDownloader = new JsonDownloader(); try { GithubModel response = await jsonDownloader.GetObject <GithubModel>("https://api.github.com/repos/adrianmteo/Luna/releases/latest"); Version newVersion = new Version(response.tag_name.Substring(1)); if (newVersion > LocalVersion) { Logger.Info("Found new update with version {0}", newVersion); GithubModel.Assets asset = response.assets.First(e => e.name.ToLower().Contains("exe")); Model.Version = newVersion.ToString(); Model.DownloadUrl = asset.browser_download_url; Model.DownloadName = asset.name; if (AutoUpdate) { await DownloadUpdate(); } else { Model.Status = UpdateStatus.NewUpdate; } } else { Logger.Info("No new updates found..."); Model.Status = UpdateStatus.NoUpdate; } } catch (Exception ex) { Logger.Error(ex.Message); Model.Status = UpdateStatus.Error; } }
private void TriggerTeamCityBuild(GithubModel model) { var branch = model.Ref.Replace("refs/heads/", ""); var buildConfId = ""; var branchName = string.Empty; if (branch.StartsWith("feature") || branch.StartsWith("bugfix")) { buildConfId = "SkyeEditor_Features"; branchName = branch.Substring(branch.LastIndexOf('/') + 1); } if (branch.StartsWith("release")) { //todo this seems not to work check http://ci.innoveo.com/viewType.html?buildTypeId=SkyeEditor_Release&branch_SkyeEditor_Releases=skye-editor-4.23.0&tab=buildTypeStatusDiv buildConfId = "SkyeEditor_Release"; //LAURENT: TODO move to settings var releaseBranchNamePrefix = "/skye-editor-"; branchName = branch.Substring(branch.LastIndexOf(releaseBranchNamePrefix, StringComparison.Ordinal) + releaseBranchNamePrefix.Length); } if (string.IsNullOrWhiteSpace(branchName)) return; StartBuildAsync(buildConfId, branchName); }
public async Task ShowGithubSource([Remainder] string _ = "") { GithubModel gm = GithubParser.GetModel(); EmbedBuilder ebm = await GithubEmbedBuilder.MakeGithubEmbed(gm, Context); await Context.Channel.SendMessageAsync(embed : ebm.Build()); }
private static string BuildMessage(GithubModel model) { var branch = model.Ref.Replace("refs/heads/", ""); var authorNames = model.Commits.Select(c => c.Author.Name).Distinct(); var stringBuilder = new StringBuilder(); stringBuilder .AppendFormat( "<b>{0}</b> committed on <a href='{1}'>{2}</a><br/>", string.Join(", ", authorNames), model.Repository.HtmlUrl + "/tree/" + branch, branch ); foreach (var commit in model.Commits) { stringBuilder .AppendFormat( @"- {0} (<a href='{1}'>{2}</a>)<br/>", commit.Message, commit.Url, commit.Id.Substring(0, 11)); } return(stringBuilder.ToString()); }
private IEnumerable<string> BuildMessages(GithubModel model) { var branch = model.Ref.Replace("refs/heads/", ""); var authorNames = model.Commits.Select(c => c.Author.Name).Distinct(); var stringBuilder = new StringBuilder(); stringBuilder .AppendFormat( "<b>{0}</b> committed on <a href='{1}'>{2}</a><br/>", string.Join(", ", authorNames), model.Repository.HtmlUrl + "/tree/" + branch, branch ); foreach (var commit in model.Commits) { stringBuilder .AppendFormat( @"- {0} (<a href='{1}'>{2}</a>)<br/>", commit.Message, commit.Url, commit.Id.Substring(0, 11)); yield return stringBuilder.ToString(); } }
private void OnPush(GithubModel githubModel) { if (githubModel.Deleted) { return; } TriggerTeamCityBuild(githubModel); }
public async Task <IActionResult> Index() { var model = new GithubModel(); if (User.Identity.IsAuthenticated) { model.GitHubName = User.FindFirst(c => c.Type == ClaimTypes.Name)?.Value; model.GitHubLogin = User.FindFirst(c => c.Type == "urn:github:login")?.Value; model.GitHubUrl = User.FindFirst(c => c.Type == "urn:github:url")?.Value; model.GitHubAvatar = User.FindFirst(c => c.Type == "urn:github:avatar")?.Value; string accessToken = await HttpContext.GetTokenAsync("access_token"); var github = new GitHubClient(new ProductHeaderValue("OAuthIntegrationTest"), // productheadervalue will be your application name on github OAuth new InMemoryCredentialStore(new Credentials(accessToken))); model.Repositories = await github.Repository.GetAllForCurrent(); } return(View(model)); }
private static (string Title, string Text) BuildMessage(GithubModel model) { var branch = model.Ref.Replace("refs/heads/", ""); var authorNames = model.Commits.Select(c => c.Author.Name).Distinct().ToList(); var title = $"{string.Join(", ", authorNames)} committed on {branch}"; var stringBuilder = new StringBuilder(); stringBuilder.AppendLine( $"**{string.Join(", ", authorNames)}** committed on [{branch}]({model.Repository.HtmlUrl + "/tree/" + branch})"); stringBuilder.AppendLine(); foreach (var commit in model.Commits.Reverse()) { stringBuilder.AppendLine($@"* {commit.Message} [{commit.Id.Substring(0, 11)}]({commit.Url})"); stringBuilder.AppendLine(); } return(title, stringBuilder.ToString()); }
public GithubPushNotification(GithubModel githubModel) { GithubModel = githubModel; }
public async Task <HttpStatusCode> Build([FromBody] GithubModel githubModel) { await _mediator.Publish(new GithubPushNotification(githubModel)); return(HttpStatusCode.OK); }