feat(Appveyor): 增加首页显示Gitee Appveyor编译版本

This commit is contained in:
Argo Zhang 2019-05-17 12:13:22 +08:00
parent 9585c8fe28
commit 36656b4a78
2 changed files with 67 additions and 7 deletions

View File

@ -19,11 +19,13 @@ namespace Bootstrap.Admin.Controllers.Api
/// ///
/// </summary> /// </summary>
/// <param name="httpClientFactory"></param> /// <param name="httpClientFactory"></param>
/// <param name="userName"></param>
/// <param name="repoName"></param>
/// <returns></returns> /// <returns></returns>
public async Task<ActionResult> Issues([FromServices]IHttpClientFactory httpClientFactory) public async Task<ActionResult> Issues([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
{ {
var client = httpClientFactory.CreateClient(); var client = httpClientFactory.CreateClient();
var content = await client.GetStringAsync("https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues"); var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/issues");
var regex = Regex.Matches(content, "<div class='ui mini circular label'>([\\d]+)</div>", RegexOptions.IgnoreCase); var regex = Regex.Matches(content, "<div class='ui mini circular label'>([\\d]+)</div>", RegexOptions.IgnoreCase);
var labels = new string[] { "open", "closed", "rejected" }; var labels = new string[] { "open", "closed", "rejected" };
var result = regex.Select((m, i) => $"{labels[i]} {m.Groups[1].Value}"); var result = regex.Select((m, i) => $"{labels[i]} {m.Groups[1].Value}");
@ -34,14 +36,69 @@ namespace Bootstrap.Admin.Controllers.Api
/// ///
/// </summary> /// </summary>
/// <param name="httpClientFactory"></param> /// <param name="httpClientFactory"></param>
/// <param name="userName"></param>
/// <param name="repoName"></param>
/// <returns></returns> /// <returns></returns>
public async Task<ActionResult> Releases([FromServices]IHttpClientFactory httpClientFactory) public async Task<ActionResult> Pulls([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
{ {
var client = httpClientFactory.CreateClient(); var client = httpClientFactory.CreateClient();
var content = await client.GetStringAsync("https://gitee.com/LongbowEnterprise/BootstrapAdmin/releases"); var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/pulls");
var regex = Regex.Match(content, "<a href=\"/LongbowEnterprise/BootstrapAdmin/releases/([^\\s]+)\" target=\"_blank\">", RegexOptions.IgnoreCase); var regex = Regex.Matches(content, "<div class='ui mini circular label'>([\\d]+)</div>", RegexOptions.IgnoreCase);
var labels = new string[] { "open", "merged", "closed" };
var result = regex.Select((m, i) => $"{labels[i]} {m.Groups[1].Value}");
return new JsonResult(new { schemaVersion = 1, label = string.Join(" ", result), message = "sweet world", color = "orange" });
}
/// <summary>
///
/// </summary>
/// <param name="httpClientFactory"></param>
/// <param name="userName"></param>
/// <param name="repoName"></param>
/// <returns></returns>
public async Task<ActionResult> Releases([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
{
var client = httpClientFactory.CreateClient();
var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/releases");
var regex = Regex.Match(content, $"<a href=\"/{userName}/{repoName}/releases/([^\\s]+)\" target=\"_blank\">", RegexOptions.IgnoreCase);
var result = regex.Groups[1].Value; var result = regex.Groups[1].Value;
return new JsonResult(new { schemaVersion = 1, label = result, message = "sweet world", color = "orange" }); return new JsonResult(new { schemaVersion = 1, label = result, message = "sweet world", color = "orange" });
} }
/// <summary>
///
/// </summary>
/// <param name="httpClientFactory"></param>
/// <param name="userName"></param>
/// <param name="projName"></param>
/// <returns></returns>
public async Task<ActionResult> Builds([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "ArgoZhang", [FromQuery]string projName = "bootstrapadmin")
{
var client = httpClientFactory.CreateClient();
var content = await client.GetAsJsonAsync<AppveyorBuildResult>($"https://ci.appveyor.com/api/projects/{userName}/{projName}");
return new JsonResult(new { schemaVersion = 1, label = content.Build.Version, message = "sweet world", color = "orange" });
}
/// <summary>
///
/// </summary>
private class AppveyorBuildResult
{
/// <summary>
///
/// </summary>
public Build Build { get; set; }
}
/// <summary>
///
/// </summary>
private class Build
{
/// <summary>
///
/// </summary>
public string Version { get; set; }
}
} }
} }

View File

@ -5,11 +5,14 @@
[![Gitee license](https://img.shields.io/github/license/argozhang/bootstrapadmin.svg?logo=git&logoColor=red)](https://gitee.com/LongbowEnterprise/BootstrapAdmin/blob/master/LICENSE) [![Gitee license](https://img.shields.io/github/license/argozhang/bootstrapadmin.svg?logo=git&logoColor=red)](https://gitee.com/LongbowEnterprise/BootstrapAdmin/blob/master/LICENSE)
## Gitee ## Gitee
[![Appveyor build](https://img.shields.io/endpoint.svg?logo=appveyor&label=build&url=https%3A%2F%2Fba.sdgxgz.com%2FBA%2Fapi%2FGitee%2FBuilds?projName=bootstrapadmin-9m1jm)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin-9m1jm)
[![Build Status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin-9m1jm/dev.svg?logo=appveyor&label=maser)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin-9m1jm) [![Build Status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin-9m1jm/dev.svg?logo=appveyor&label=maser)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin-9m1jm)
[![Build Status](https://img.shields.io/appveyor/tests/ArgoZhang/bootstrapadmin-9m1jm/master.svg?logo=appveyor&)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin-9m1jm/build/tests) [![Test Status](https://img.shields.io/appveyor/tests/ArgoZhang/bootstrapadmin-9m1jm/master.svg?logo=appveyor&)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin-9m1jm/build/tests)
[![Issue Status](https://img.shields.io/endpoint.svg?logo=appveyor&label=issues&url=https%3A%2F%2Fba.sdgxgz.com%2FBA%2Fapi%2FGitee%2FIssues)](https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues) [![Issue Status](https://img.shields.io/endpoint.svg?logo=Groupon&logoColor=critical&label=issues&url=https%3A%2F%2Fba.sdgxgz.com%2FBA%2Fapi%2FGitee%2FIssues)](https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues)
[![Pull Status](https://img.shields.io/endpoint.svg?logo=Groupon&logoColor=brightgreen&label=pulls&url=https%3A%2F%2Fba.sdgxgz.com%2FBA%2Fapi%2FGitee%2FPullss)](https://gitee.com/LongbowEnterprise/BootstrapAdmin/pulls)
## GitHub ## GitHub
[![Appveyor build](https://img.shields.io/endpoint.svg?logo=appveyor&label=build&url=https%3A%2F%2Fba.sdgxgz.com%2FBA%2Fapi%2FGitee%2FBuilds?projName=bootstrapadmin)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin)
[![Build status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin/dev.svg?logo=appveyor&label=dev)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/dev) [![Build status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin/dev.svg?logo=appveyor&label=dev)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/dev)
[![Build status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin/dev.svg?logo=appveyor&label=master)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/master) [![Build status](https://img.shields.io/appveyor/ci/ArgoZhang/bootstrapadmin/dev.svg?logo=appveyor&label=master)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/master)
[![Test Status](https://img.shields.io/appveyor/tests/argozhang/bootstrapadmin/master.svg?logo=appveyor&)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/master/tests) [![Test Status](https://img.shields.io/appveyor/tests/argozhang/bootstrapadmin/master.svg?logo=appveyor&)](https://ci.appveyor.com/project/ArgoZhang/bootstrapadmin/branch/master/tests)