Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0091af6ae | ||
|
|
70df39c4c8 | ||
|
|
d44f364924 | ||
|
|
4095c3c4a8 | ||
|
|
1f94f028c6 | ||
|
|
d34ba4e43a | ||
|
|
c02f05bcdf | ||
|
|
3e4cf7c554 | ||
|
|
edf737dc74 | ||
|
|
4394a97332 | ||
|
|
90476c250d | ||
|
|
48811946e3 | ||
|
|
b50b2fc5c4 | ||
|
|
efc19808f5 | ||
|
|
370bc948d2 | ||
|
|
910bdfc054 | ||
|
|
cf7e1bf3e8 | ||
|
|
6bff671384 |
38
src/CodeRelease/.editorconfig
Normal file
38
src/CodeRelease/.editorconfig
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# 全部文件
|
||||||
|
[*]
|
||||||
|
indent_style = space #指定缩进风格,可以是tab(制表符)或space(空格)
|
||||||
|
|
||||||
|
# Xml files
|
||||||
|
[*.xml]
|
||||||
|
indent_size = 2 #定义一个缩进级别的大小。
|
||||||
|
|
||||||
|
[*.cs]
|
||||||
|
end_of_line = lf #指定换行符的类型,可以是lf(Unix/Linux)、crlf(Windows)或cr(老式的Mac OS)。
|
||||||
|
indent_style = space #指定缩进风格,可以是tab(制表符)或space(空格)
|
||||||
|
charset = utf-8 #设置文件字符集为utf-8,在 Linux 系统中,通常推荐使用 UTF-8 而不是 UTF-8 with BOM。添加 BOM 可能会干扰那些不期望在文件开头出现非 ASCII 字节的软件对 UTF-8 的使用。
|
||||||
|
trim_trailing_whitespace = true #指定是否删除行尾的空白字符。
|
||||||
|
insert_final_newline = true #指定文件末尾是否应该插入一个空白行。
|
||||||
|
indent_size = 4
|
||||||
|
# 模式匹配的偏好设置
|
||||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion # 推荐使用模式匹配而非 is 与类型转换检查
|
||||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion # 推荐使用模式匹配而非 as 与 null 检查
|
||||||
|
|
||||||
|
# 空检查的偏好设置
|
||||||
|
csharp_style_throw_expression = true:suggestion # 推荐使用 throw 表达式
|
||||||
|
csharp_style_conditional_delegate_call = true:suggestion # 推荐使用条件委托调用
|
||||||
|
|
||||||
|
# 修饰符的偏好设置
|
||||||
|
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion # 修饰符的推荐顺序
|
||||||
|
|
||||||
|
# 表达式级别的偏好设置
|
||||||
|
csharp_prefer_braces = true:silent # 推荐使用大括号,即使在可能省略的情况下
|
||||||
|
csharp_style_deconstructed_variable_declaration = true:suggestion # 推荐使用解构变量声明
|
||||||
|
csharp_prefer_simple_default_expression = true:suggestion # 推荐使用简化的默认值表达式
|
||||||
|
csharp_style_prefer_local_over_anonymous_function = true:suggestion # 推荐使用本地函数而非匿名函数
|
||||||
|
csharp_style_inlined_variable_declaration = true:suggestion # 推荐内联变量声明
|
||||||
|
# 首选顶层语句的偏好设置
|
||||||
|
csharp_style_prefer_top_level_statements = true:silent # 推荐使用顶层语句,不强制要求
|
||||||
|
|
||||||
|
|
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.10.34916.146
|
VisualStudioVersion = 17.10.34916.146
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeRelease", "CodeRelease\CodeRelease.csproj", "{C58D2D43-B90B-4CEA-810F-99027F8F865A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeRelease", "CodeRelease\CodeRelease.csproj", "{C58D2D43-B90B-4CEA-810F-99027F8F865A}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{74FD82FD-055B-45E9-AE81-0CAFDF083ECB}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
13
src/CodeRelease/CodeRelease/.config/dotnet-tools.json
Normal file
13
src/CodeRelease/CodeRelease/.config/dotnet-tools.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "8.0.6",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/CodeRelease/CodeRelease/.editorconfig
Normal file
5
src/CodeRelease/CodeRelease/.editorconfig
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
root = true
|
||||||
|
[*.cs]
|
||||||
|
charset = utf-8 #设置文件字符集为utf-8,在 Linux 系统中,通常推荐使用 UTF-8 而不是 UTF-8 with BOM。添加 BOM 可能会干扰那些不期望在文件开头出现非 ASCII 字节的软件对 UTF-8 的使用。
|
||||||
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
using System.Diagnostics;
|
using CodeRelease.Model;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace CodeRelease.BLL
|
namespace CodeRelease.BLL
|
||||||
{
|
{
|
||||||
|
|
@ -19,6 +28,7 @@ namespace CodeRelease.BLL
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Log.Logger.Information($"开始执行linux {command}");
|
||||||
// 创建一个新的进程
|
// 创建一个新的进程
|
||||||
using (Process process = new Process())
|
using (Process process = new Process())
|
||||||
{
|
{
|
||||||
|
|
@ -32,19 +42,24 @@ namespace CodeRelease.BLL
|
||||||
// 绑定输出和错误数据接收事件
|
// 绑定输出和错误数据接收事件
|
||||||
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
|
//Log.Logger.Information($"linux执行出错OutputDataReceived,命令{command}");
|
||||||
|
//Log.Logger.Information($"linux执行出错OutputDataReceived,Output{JsonConvert.SerializeObject(e)}");
|
||||||
if (!string.IsNullOrEmpty(e.Data))
|
if (!string.IsNullOrEmpty(e.Data))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Output: {e.Data}");
|
//Console.WriteLine($"Output: {e.Data}");
|
||||||
outputDataReceived = e.Data;
|
|
||||||
|
outputDataReceived += e.Data + "\n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
|
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
|
// Log.Logger.Information($"linux执行出错ErrorDataReceived,命令{command}");
|
||||||
|
//Log.Logger.Information($"linux执行出错ErrorDataReceived,Output:{JsonConvert.SerializeObject(e)}");
|
||||||
if (!string.IsNullOrEmpty(e.Data))
|
if (!string.IsNullOrEmpty(e.Data))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error: {e.Data}");
|
//Console.WriteLine($"Error: {e.Data}");
|
||||||
errorDataReceived = e.Data;
|
errorDataReceived += e.Data + "\n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -59,13 +74,16 @@ namespace CodeRelease.BLL
|
||||||
await process.WaitForExitAsync();
|
await process.WaitForExitAsync();
|
||||||
|
|
||||||
// 输出退出代码
|
// 输出退出代码
|
||||||
Console.WriteLine($"Process exited with code {process.ExitCode}");
|
//Console.WriteLine($"Process exited with code {process.ExitCode}");
|
||||||
|
Log.Logger.Information($"执行结束:{process.ExitCode}");
|
||||||
|
Log.Logger.Information($"{outputDataReceived}");
|
||||||
|
Log.Logger.Information($"{errorDataReceived}");
|
||||||
exitCode = process.ExitCode;
|
exitCode = process.ExitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Exception: {ex.Message}");
|
Log.Logger.Information($"执行出现异常结束 {ex.Message}");
|
||||||
}
|
}
|
||||||
return new { exitCode, outputDataReceived, errorDataReceived };
|
return new { exitCode, outputDataReceived, errorDataReceived };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
|
@ -7,7 +7,23 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.0.0" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EditorConfigFiles Remove="I:\Gitea\server\CodeRelease\src\CodeRelease\CodeRelease\.editorconfig" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="I:\Gitea\server\CodeRelease\src\CodeRelease\CodeRelease\.editorconfig" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,25 @@
|
||||||
using CodeRelease.BLL;
|
using CodeRelease.BLL;
|
||||||
|
using CodeRelease.Model;
|
||||||
|
using CodeRelease.Utile;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace CodeRelease.Controllers
|
namespace CodeRelease.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
[Route("api/[controller]/[Action]")]
|
[Route("api/[controller]/[Action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class PublishController : ControllerBase
|
public class PublishController() : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|
@ -16,11 +27,86 @@ namespace CodeRelease.Controllers
|
||||||
/// 测试
|
/// 测试
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<object> Test()
|
public async Task<object> Test([FromBody] object data)
|
||||||
{
|
{
|
||||||
|
var jsonStr = data.ToString();
|
||||||
|
var jObject = JsonConvert.DeserializeObject<JObject>(jsonStr);
|
||||||
LinuxExecuteCommand linuxExecuteCommand = new LinuxExecuteCommand();
|
LinuxExecuteCommand linuxExecuteCommand = new LinuxExecuteCommand();
|
||||||
var obj = await linuxExecuteCommand.ExecuteCommand("make test -f /disk/CodeRelease/test/makefile");
|
var obj = await linuxExecuteCommand.ExecuteCommand("make test -f /disk/CodeRelease/test/makefile");
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
/// <summary>
|
||||||
|
/// 发布
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<object> ReleaseAction([FromBody] object data, [FromServices] GiteaWebhookConfigModel giteaWebhookConfig)
|
||||||
|
{
|
||||||
|
Log.Logger.Information("执行发布接口,参数{data}", data);
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
//MaxDepth = 64 // 设置一个足够大的值,默认值是 32
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var jsonStr = data.ToString() ?? "";
|
||||||
|
var releaseAction = JsonConvert.DeserializeObject<PublishAction>(jsonStr, settings);
|
||||||
|
|
||||||
|
if (releaseAction != null)
|
||||||
|
{
|
||||||
|
if (releaseAction.Action == "published")
|
||||||
|
{
|
||||||
|
if (releaseAction.Release.Assets?.Count > 0)
|
||||||
|
{
|
||||||
|
var url = releaseAction.Release.Assets[0].BrowserDownloadUrl;
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
var version = releaseAction.Release.TagName;
|
||||||
|
var fileName = Path.GetFileName(url);
|
||||||
|
var download = giteaWebhookConfig.BrowserDownloadFileUrl + version + "/";
|
||||||
|
if (!Directory.Exists(download))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(download);
|
||||||
|
}
|
||||||
|
FileDownloader fileDownloader = new FileDownloader();
|
||||||
|
//giteaWebhookConfig.BrowserDownloadFileUrl.Replace("{version}", version);
|
||||||
|
await fileDownloader.DownloadFileAsync(url, download + fileName);
|
||||||
|
ZipExtractor extractor = new ZipExtractor();
|
||||||
|
var temp = fileName.Substring(0, fileName.LastIndexOf("."));
|
||||||
|
extractor.ExtractZipFile(download + fileName, download + "/" + temp);
|
||||||
|
var mingling = giteaWebhookConfig.MakeFile.Replace("{version}", version).Replace("{dir_file_path}", download + "/" + temp + "/");
|
||||||
|
LinuxExecuteCommand linuxExecuteCommand = new LinuxExecuteCommand();
|
||||||
|
//make public version=0.0.1 dir_file_path=/
|
||||||
|
var obj = await linuxExecuteCommand.ExecuteCommand(mingling);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(releaseAction.Release.TargetCommitish))
|
||||||
|
{
|
||||||
|
var version = releaseAction.Release.TagName;
|
||||||
|
var mingling = giteaWebhookConfig.MakeFile
|
||||||
|
.Replace("{version}", version)
|
||||||
|
.Replace("{description}", releaseAction.Release.Body)
|
||||||
|
.Replace("{name}", version)
|
||||||
|
//.Replace("{version}", version)
|
||||||
|
//.Replace("{version}", version)
|
||||||
|
//.Replace("{version}", version)
|
||||||
|
//.Replace("{dir_file_path}", download + "/")
|
||||||
|
.Replace("{target_commitish}", releaseAction.Release.TargetCommitish);
|
||||||
|
Log.Logger.Information("执行linux命令{mingling}", mingling);
|
||||||
|
LinuxExecuteCommand linuxExecuteCommand = new LinuxExecuteCommand();
|
||||||
|
//make public version=0.0.1 dir_file_path=/
|
||||||
|
var obj = await linuxExecuteCommand.ExecuteCommand(mingling);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
966
src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs
Normal file
966
src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs
Normal file
|
|
@ -0,0 +1,966 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
namespace CodeRelease.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发布动作类
|
||||||
|
/// </summary>
|
||||||
|
public class PublishAction
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发布的动作
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("action")]
|
||||||
|
public string Action { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("release")]
|
||||||
|
public Release Release { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("repository")]
|
||||||
|
public Repository Repository { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发送者信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("sender")]
|
||||||
|
public Sender Sender { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布信息类
|
||||||
|
/// </summary>
|
||||||
|
public class Release
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发布ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("tag_name")]
|
||||||
|
public string TagName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标分支
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("target_commitish")]
|
||||||
|
public string TargetCommitish { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布描述
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("body")]
|
||||||
|
public string Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布HTML URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("html_url")]
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tarball文件URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("tarball_url")]
|
||||||
|
public string TarballUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// zipball文件URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("zipball_url")]
|
||||||
|
public string ZipballUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上传URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("upload_url")]
|
||||||
|
public string UploadUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为草稿
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("draft")]
|
||||||
|
public bool Draft { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为预发布
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("prerelease")]
|
||||||
|
public bool Prerelease { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("created_at")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("published_at")]
|
||||||
|
public DateTime PublishedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 作者信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("author")]
|
||||||
|
public Author Author { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资产列表
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("assets")]
|
||||||
|
public List<Asset> Assets { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 作者信息类
|
||||||
|
/// </summary>
|
||||||
|
public class Author
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 作者ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("login")]
|
||||||
|
public string Login { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("login_name")]
|
||||||
|
public string LoginName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来源ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("source_id")]
|
||||||
|
public int SourceId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全名
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("full_name")]
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 邮箱
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("email")]
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 头像URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("avatar_url")]
|
||||||
|
public string AvatarUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HTML URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("html_url")]
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 语言
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("language")]
|
||||||
|
public string Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为管理员
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("is_admin")]
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后登录时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("last_login")]
|
||||||
|
public DateTime LastLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("created")]
|
||||||
|
public DateTime Created { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否受限
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("restricted")]
|
||||||
|
public bool Restricted { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否活跃
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("active")]
|
||||||
|
public bool Active { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁止登录
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("prohibit_login")]
|
||||||
|
public bool ProhibitLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位置
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("location")]
|
||||||
|
public string Location { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 个人网站
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("website")]
|
||||||
|
public string Website { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可见性
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("visibility")]
|
||||||
|
public string Visibility { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关注者数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("followers_count")]
|
||||||
|
public int FollowersCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关注数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("following_count")]
|
||||||
|
public int FollowingCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收藏的仓库数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("starred_repos_count")]
|
||||||
|
public int StarredReposCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资产信息类
|
||||||
|
/// </summary>
|
||||||
|
public class Asset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资产ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资产名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资产大小
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("size")]
|
||||||
|
public long Size { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载次数
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("download_count")]
|
||||||
|
public int DownloadCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("created_at")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资产UUID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("uuid")]
|
||||||
|
public string Uuid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 浏览器下载URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("browser_download_url")]
|
||||||
|
public string BrowserDownloadUrl { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库信息类
|
||||||
|
/// </summary>
|
||||||
|
public class Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拥有者信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("owner")]
|
||||||
|
public Owner Owner { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库全名
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("full_name")]
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库描述
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库是否为空
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("empty")]
|
||||||
|
public bool Empty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为私有仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("private")]
|
||||||
|
public bool Private { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为派生仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("fork")]
|
||||||
|
public bool Fork { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为模板仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("template")]
|
||||||
|
public bool Template { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 父仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("parent")]
|
||||||
|
public object Parent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为镜像仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("mirror")]
|
||||||
|
public bool Mirror { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库大小
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("size")]
|
||||||
|
public long Size { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库语言
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("language")]
|
||||||
|
public string Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库语言URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("languages_url")]
|
||||||
|
public string LanguagesUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库HTML URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("html_url")]
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库API URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库链接
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("link")]
|
||||||
|
public string Link { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库SSH URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("ssh_url")]
|
||||||
|
public string SshUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库克隆 URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("clone_url")]
|
||||||
|
public string CloneUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原始 URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("original_url")]
|
||||||
|
public string OriginalUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库网站
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("website")]
|
||||||
|
public string Website { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 星标数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("stars_count")]
|
||||||
|
public int StarsCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 派生数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("forks_count")]
|
||||||
|
public int ForksCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关注者数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("watchers_count")]
|
||||||
|
public int WatchersCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开放问题数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("open_issues_count")]
|
||||||
|
public int OpenIssuesCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开放PR数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("open_pr_counter")]
|
||||||
|
public int OpenPrCounter { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发布数量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("release_counter")]
|
||||||
|
public int ReleaseCounter { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认分支
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("default_branch")]
|
||||||
|
public string DefaultBranch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存档
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("archived")]
|
||||||
|
public bool Archived { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("created_at")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("updated_at")]
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存档时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("archived_at")]
|
||||||
|
public DateTime ArchivedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限信息
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("permissions")]
|
||||||
|
public Permissions Permissions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有问题跟踪
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_issues")]
|
||||||
|
public bool HasIssues { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内部问题跟踪器
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("internal_tracker")]
|
||||||
|
public InternalTracker InternalTracker { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有Wiki
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_wiki")]
|
||||||
|
public bool HasWiki { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有PR
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_pull_requests")]
|
||||||
|
public bool HasPullRequests { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有项目
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_projects")]
|
||||||
|
public bool HasProjects { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 项目模式
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("projects_mode")]
|
||||||
|
public string ProjectsMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有发布
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_releases")]
|
||||||
|
public bool HasReleases { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有包
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_packages")]
|
||||||
|
public bool HasPackages { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有动作
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("has_actions")]
|
||||||
|
public bool HasActions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否忽略空白冲突
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("ignore_whitespace_conflicts")]
|
||||||
|
public bool IgnoreWhitespaceConflicts { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许合并提交
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_merge_commits")]
|
||||||
|
public bool AllowMergeCommits { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许变基
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_rebase")]
|
||||||
|
public bool AllowRebase { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许显式变基
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_rebase_explicit")]
|
||||||
|
public bool AllowRebaseExplicit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许快速前进合并
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_squash_merge")]
|
||||||
|
public bool AllowSquashMerge { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否仅允许快速前进合并
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_fast_forward_only_merge")]
|
||||||
|
public bool AllowFastForwardOnlyMerge { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许变基更新
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("allow_rebase_update")]
|
||||||
|
public bool AllowRebaseUpdate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在合并后默认删除分支
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("default_delete_branch_after_merge")]
|
||||||
|
public bool DefaultDeleteBranchAfterMerge { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认合并样式
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("default_merge_style")]
|
||||||
|
public string DefaultMergeStyle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否默认允许维护者编辑
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("default_allow_maintainer_edit")]
|
||||||
|
public bool DefaultAllowMaintainerEdit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 头像URL
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("avatar_url")]
|
||||||
|
public string AvatarUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为内部仓库
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("internal")]
|
||||||
|
public bool Internal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 镜像间隔
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("mirror_interval")]
|
||||||
|
public string MirrorInterval { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对象格式名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("object_format_name")]
|
||||||
|
public string ObjectFormatName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 镜像更新时间
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("mirror_updated")]
|
||||||
|
public DateTime MirrorUpdated { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库转移
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("repo_transfer")]
|
||||||
|
public object RepoTransfer { get; set; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库所有者
|
||||||
|
/// </summary>
|
||||||
|
public class Owner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 所有者ID
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名
|
||||||
|
/// </summary>
|
||||||
|
public string Login { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名称
|
||||||
|
/// </summary>
|
||||||
|
public string LoginName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来源ID
|
||||||
|
/// </summary>
|
||||||
|
public int SourceId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全名
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 邮箱
|
||||||
|
/// </summary>
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 头像 URL
|
||||||
|
/// </summary>
|
||||||
|
public string AvatarUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HTML URL
|
||||||
|
/// </summary>
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 语言
|
||||||
|
/// </summary>
|
||||||
|
public string Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为管理员
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后登录时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LastLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Created { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否受限
|
||||||
|
/// </summary>
|
||||||
|
public bool Restricted { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否活跃
|
||||||
|
/// </summary>
|
||||||
|
public bool Active { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁止登录
|
||||||
|
/// </summary>
|
||||||
|
public bool ProhibitLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位置
|
||||||
|
/// </summary>
|
||||||
|
public string Location { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网站
|
||||||
|
/// </summary>
|
||||||
|
public string Website { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可见性
|
||||||
|
/// </summary>
|
||||||
|
public string Visibility { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 粉丝数量
|
||||||
|
/// </summary>
|
||||||
|
public int FollowersCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关注数量
|
||||||
|
/// </summary>
|
||||||
|
public int FollowingCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 星标仓库数量
|
||||||
|
/// </summary>
|
||||||
|
public int StarredReposCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
public string Username { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限
|
||||||
|
/// </summary>
|
||||||
|
public class Permissions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为管理员
|
||||||
|
/// </summary>
|
||||||
|
public bool Admin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许推送
|
||||||
|
/// </summary>
|
||||||
|
public bool Push { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许拉取
|
||||||
|
/// </summary>
|
||||||
|
public bool Pull { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内部跟踪器
|
||||||
|
/// </summary>
|
||||||
|
public class InternalTracker
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用时间跟踪
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableTimeTracker { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否仅允许贡献者跟踪时间
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowOnlyContributorsToTrackTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用问题依赖
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIssueDependencies { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 触发发布的用户
|
||||||
|
/// </summary>
|
||||||
|
public class Sender
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名
|
||||||
|
/// </summary>
|
||||||
|
public string Login { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录名称
|
||||||
|
/// </summary>
|
||||||
|
public string LoginName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来源ID
|
||||||
|
/// </summary>
|
||||||
|
public int SourceId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全名
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 邮箱
|
||||||
|
/// </summary>
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 头像 URL
|
||||||
|
/// </summary>
|
||||||
|
public string AvatarUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HTML URL
|
||||||
|
/// </summary>
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 语言
|
||||||
|
/// </summary>
|
||||||
|
public string Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为管理员
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后登录时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LastLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Created { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否受限
|
||||||
|
/// </summary>
|
||||||
|
public bool Restricted { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否活跃
|
||||||
|
/// </summary>
|
||||||
|
public bool Active { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁止登录
|
||||||
|
/// </summary>
|
||||||
|
public bool ProhibitLogin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位置
|
||||||
|
/// </summary>
|
||||||
|
public string Location { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网站
|
||||||
|
/// </summary>
|
||||||
|
public string Website { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可见性
|
||||||
|
/// </summary>
|
||||||
|
public string Visibility { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 粉丝数量
|
||||||
|
/// </summary>
|
||||||
|
public int FollowersCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关注数量
|
||||||
|
/// </summary>
|
||||||
|
public int FollowingCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 星标仓库数量
|
||||||
|
/// </summary>
|
||||||
|
public int StarredReposCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
public string Username { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
21
src/CodeRelease/CodeRelease/Model/GiteaWebhookConfigModel.cs
Normal file
21
src/CodeRelease/CodeRelease/Model/GiteaWebhookConfigModel.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
namespace CodeRelease.Model
|
||||||
|
{
|
||||||
|
public class GiteaWebhookConfigModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 名字
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// make命令
|
||||||
|
/// </summary>
|
||||||
|
public string MakeFile { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 下载后地址
|
||||||
|
/// </summary>
|
||||||
|
public string BrowserDownloadFileUrl { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,40 @@
|
||||||
|
using CodeRelease.Model;
|
||||||
|
using CodeRelease.Utile;
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using Serilog;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Serilog.Events;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
var configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
//.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var logger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(configuration)
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
//.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
//.AddJsonFile("appsettings.json")
|
||||||
|
.WriteTo.Console()
|
||||||
|
.WriteTo.Debug()
|
||||||
|
.WriteTo.File("../output/Logs/clog-.txt", LogEventLevel.Debug, rollingInterval: RollingInterval.Day)
|
||||||
|
.CreateLogger();
|
||||||
|
builder.Logging.ClearProviders(); // 清空默认的日志记录器
|
||||||
|
builder.Logging.AddConsole();
|
||||||
|
builder.Logging.AddSerilog();
|
||||||
|
builder.Services.AddSerilog();
|
||||||
|
builder.Host.UseSerilog();
|
||||||
|
logger.Information("启动项目");
|
||||||
|
// Add services to the container.
|
||||||
|
var giteaWebhookConfigModelList = builder.Configuration.GetSection("GiteaWebhookConfig").Get<List<GiteaWebhookConfigModel>>() ?? new List<GiteaWebhookConfigModel>();
|
||||||
|
builder.Services.AddSingleton(giteaWebhookConfigModelList);
|
||||||
|
builder.Services.AddScoped<GiteaWebhookConfigModel>();
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
@ -19,8 +52,32 @@ if (app.Environment.IsDevelopment())
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
app.UseMiddleware<GiteaWebhookConfigMiddleware>();
|
||||||
|
app.UseSerilogRequestLogging();
|
||||||
app.MapGet("/", () =>
|
app.MapGet("/", () =>
|
||||||
{
|
{
|
||||||
return "请求成功";
|
return "请求成功";
|
||||||
}).WithName("默认请求");
|
}).WithName("默认请求");
|
||||||
|
|
||||||
|
var startDateTime = DateTime.Now;
|
||||||
|
var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
|
//Console.WriteLine($"version:{InformationalVersion}");
|
||||||
|
app.MapGet("/system", () =>
|
||||||
|
{
|
||||||
|
|
||||||
|
using Process currentProcess = Process.GetCurrentProcess();
|
||||||
|
// CPU使用率 (一般是一个0-100之间的值,但实际是时间占比,需要转换)
|
||||||
|
double cpuUsage = currentProcess.TotalProcessorTime.TotalMilliseconds / Environment.TickCount * 100;
|
||||||
|
// 已用内存 (字节)
|
||||||
|
long memoryUsage = currentProcess.WorkingSet64;
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
msg = $"系统版本:{InformationalVersion},启动时间:{startDateTime.ToString("yyyy-MM-dd HH:mm:ss")},已安全运行时间:{DateTime.Now.Subtract(startDateTime).TotalMinutes.ToString("0.##")}分钟",
|
||||||
|
InformationalVersion,
|
||||||
|
startDateTime,
|
||||||
|
MemoryUsage = $"{memoryUsage / (1024.0 * 1024.0):F2}MB",
|
||||||
|
CPUUsage = $"{cpuUsage:F2}%"
|
||||||
|
|
||||||
|
};
|
||||||
|
}).WithName("获取系统数据");
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
|
||||||
51
src/CodeRelease/CodeRelease/Utile/FileDownloader.cs
Normal file
51
src/CodeRelease/CodeRelease/Utile/FileDownloader.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
namespace CodeRelease.Utile
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件
|
||||||
|
/// </summary>
|
||||||
|
public class FileDownloader
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public FileDownloader()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件并将其保存到指定路径。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileUrl">要下载的文件的 URL。</param>
|
||||||
|
/// <param name="destinationFilePath">保存文件的路径。</param>
|
||||||
|
/// <returns>异步任务。</returns>
|
||||||
|
public async Task<bool> DownloadFileAsync(string fileUrl, string destinationFilePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (HttpClient _client = new HttpClient())
|
||||||
|
{
|
||||||
|
// 发送 HTTP GET 请求
|
||||||
|
HttpResponseMessage response = await _client.GetAsync(fileUrl);
|
||||||
|
|
||||||
|
// 确认响应状态是成功
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
// 读取响应内容为字节数组
|
||||||
|
byte[] fileBytes = await response.Content.ReadAsByteArrayAsync();
|
||||||
|
|
||||||
|
// 将字节数组写入文件
|
||||||
|
await File.WriteAllBytesAsync(destinationFilePath, fileBytes);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
//Console.WriteLine("文件下载成功!");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"文件下载失败: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
using CodeRelease.Model;
|
||||||
|
|
||||||
|
namespace CodeRelease.Utile
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class GiteaWebhookConfigMiddleware
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
|
||||||
|
|
||||||
|
public GiteaWebhookConfigMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
_next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext context,
|
||||||
|
List<GiteaWebhookConfigModel> giteaWebhookConfigModels,
|
||||||
|
GiteaWebhookConfigModel giteaWebhookConfig)
|
||||||
|
{
|
||||||
|
context.Request.Headers.TryGetValue("Authorization", out var authorization);
|
||||||
|
var key = authorization.ToString();
|
||||||
|
if (!string.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
var tempgiteaWebhookConfig = giteaWebhookConfigModels.FirstOrDefault(it => it.Name == key);
|
||||||
|
if (tempgiteaWebhookConfig == null)
|
||||||
|
{
|
||||||
|
if (giteaWebhookConfigModels.Count > 0)
|
||||||
|
{
|
||||||
|
tempgiteaWebhookConfig = giteaWebhookConfigModels[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempgiteaWebhookConfig = new GiteaWebhookConfigModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
giteaWebhookConfig.BrowserDownloadFileUrl = tempgiteaWebhookConfig.BrowserDownloadFileUrl;
|
||||||
|
giteaWebhookConfig.Name = tempgiteaWebhookConfig.Name;
|
||||||
|
giteaWebhookConfig.MakeFile = tempgiteaWebhookConfig.MakeFile;
|
||||||
|
}
|
||||||
|
await _next(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
35
src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs
Normal file
35
src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.IO.Compression;
|
||||||
|
namespace CodeRelease.Utile
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 解压文件
|
||||||
|
/// </summary>
|
||||||
|
public class ZipExtractor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 解压ZIP文件到指定目录。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="zipFilePath">ZIP 文件路径。</param>
|
||||||
|
/// <param name="extractPath">解压目标目录。</param>
|
||||||
|
public void ExtractZipFile(string zipFilePath, string extractPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 确保目标目录存在
|
||||||
|
if (!Directory.Exists(extractPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(extractPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解压缩文件
|
||||||
|
ZipFile.ExtractToDirectory(zipFilePath, extractPath);
|
||||||
|
|
||||||
|
//Console.WriteLine("文件解压成功!");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"文件解压失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,14 +5,74 @@
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//日志
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Debug",
|
||||||
|
"WriteTo": [
|
||||||
|
{ "Name": "Console" },
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "../output/Logs/log-.txt",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||||
|
"Destructure": [
|
||||||
|
{
|
||||||
|
"Name": "ToMaximumDepth",
|
||||||
|
"Args": { "maximumDestructuringDepth": 4 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "ToMaximumStringLength",
|
||||||
|
"Args": { "maximumStringLength": 100 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "ToMaximumCollectionCount",
|
||||||
|
"Args": { "maximumCollectionCount": 10 }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "Sample"
|
||||||
|
}
|
||||||
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5240"
|
"Url": "http://*:82"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//web 钩子配置
|
||||||
|
"GiteaWebhookConfig": [
|
||||||
|
{
|
||||||
|
"Name": "coderelease",
|
||||||
|
//make 文件位置
|
||||||
|
"MakeFile": " make public version={version} target_commitish={target_commitish} -f /disk/Public/coderelease/makefile",
|
||||||
|
//发布文件下载位置
|
||||||
|
"BrowserDownloadFileUrl": ""
|
||||||
|
//
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "aiweb",
|
||||||
|
//make 文件位置
|
||||||
|
"MakeFile": "make public version={version} dir_file_path={dir_file_path} -f /disk/Public/aiweb/makefile",
|
||||||
|
//发布文件下载位置
|
||||||
|
"BrowserDownloadFileUrl": "/disk/Public/aiweb/"
|
||||||
|
//
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "miaoyu",
|
||||||
|
//make 文件位置 make public version=0.0.2 target_commitish=dev -f /disk/Public/miaoyu/makefile
|
||||||
|
"MakeFile": "make public version={version} target_commitish={target_commitish} -f /disk/Public/miaoyu/makefile",
|
||||||
|
//发布文件下载位置
|
||||||
|
"BrowserDownloadFileUrl": ""
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,21 @@
|
||||||
SHELL=/usr/bin/env bash
|
SHELL=/usr/bin/env bash
|
||||||
date_dir_name = $(shell date +"%Y%m%d-%H%M%S")
|
date_dir_name = $(shell date +"%Y%m%d-%H%M%S")
|
||||||
|
dir_file_path=/disk
|
||||||
|
backups_dir_path=/disk/web/backups
|
||||||
|
version=0.0.1
|
||||||
|
server_dir_path=/var/www/web/
|
||||||
test:
|
test:
|
||||||
@echo $(date_dir_name)
|
@echo $(date_dir_name)
|
||||||
|
@echo $(dir_file)
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
# make public version=0.0.1 dir_file_path=/
|
||||||
|
#make var dir_file_path=aaa
|
||||||
|
@echo $(date_dir_name)
|
||||||
|
# 创建备份文件夹
|
||||||
|
mkdir -p $(backups_dir_path)/$(version)/$(date_dir_name)
|
||||||
|
# 从服务器同步到本地,备份
|
||||||
|
rsync -avz ubuntu@101.43.19.200:$(server_dir_path) $(backups_dir_path)/$(version)/$(date_dir_name)
|
||||||
|
# 从本地同步到服务器
|
||||||
|
rsync -avz $(dir_file_path) ubuntu@101.43.19.200:$(server_dir_path)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user