diff --git a/src/client/Bootstrap.Client/Controllers/Api/DeployController.cs b/src/client/Bootstrap.Client/Controllers/Api/DeployController.cs
deleted file mode 100644
index d12f9ab2..00000000
--- a/src/client/Bootstrap.Client/Controllers/Api/DeployController.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Bootstrap.Client.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Bootstrap.Client.Controllers.Api
-{
- ///
- /// 自动发布 WebApi 接口
- ///
- [Route("api/[controller]")]
- [ApiController]
- [AllowAnonymous]
- public class DeployController : ControllerBase
- {
- ///
- /// 自动发布 webhook 接口
- ///
- ///
- [HttpPost]
- public void Post([FromBody]GiteePushEventArgs args)
- {
- DeployTaskManager.Add(args);
- }
- }
-}
diff --git a/src/client/Bootstrap.Client/Startup.cs b/src/client/Bootstrap.Client/Startup.cs
index a80b761f..70e9c2b5 100644
--- a/src/client/Bootstrap.Client/Startup.cs
+++ b/src/client/Bootstrap.Client/Startup.cs
@@ -1,9 +1,7 @@
using Bootstrap.Client.DataAccess;
-using Longbow.Web;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Configuration;
@@ -48,7 +46,6 @@ namespace Bootstrap.Client
services.AddBootstrapHttpClient();
services.AddIPLocator(DictHelper.ConfigIPLocator);
services.AddOnlineUsers();
- services.AddAutoPublish();
services.AddBootstrapAdminAuthentication(Configuration);
services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build());
diff --git a/src/client/Bootstrap.Client/Tasks/DeployExtensions.cs b/src/client/Bootstrap.Client/Tasks/DeployExtensions.cs
deleted file mode 100644
index 553286c6..00000000
--- a/src/client/Bootstrap.Client/Tasks/DeployExtensions.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Bootstrap.Client.Tasks;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- ///
- /// 自动发布服务扩展操作类
- ///
- public static class DeployExtensions
- {
- ///
- /// 注入自动发布到容器内
- ///
- ///
- ///
- public static IServiceCollection AddAutoPublish(this IServiceCollection services)
- {
- DeployTaskManager.RegisterServices(services);
- return services;
- }
- }
-}
diff --git a/src/client/Bootstrap.Client/Tasks/DeployOptions.cs b/src/client/Bootstrap.Client/Tasks/DeployOptions.cs
deleted file mode 100644
index 717e5765..00000000
--- a/src/client/Bootstrap.Client/Tasks/DeployOptions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace Bootstrap.Client.Tasks
-{
- ///
- /// 自动发布配置类
- ///
- public class DeployOptions
- {
- ///
- /// 获得/设置 是否启用自动部署功能
- ///
- public bool Enabled { get; set; }
-
- ///
- /// 获得/设置 自动部署脚本文件
- ///
- public string DeployFile { get; set; } = "";
-
- ///
- /// 获得/设置 自动部署分支
- ///
- public string Branch { get; set; } = "release";
-
- ///
- /// 获得/设置 自动部署平台
- ///
- public string OSPlatform { get; set; } = "Windows";
- }
-}
diff --git a/src/client/Bootstrap.Client/Tasks/DeployTaskManager.cs b/src/client/Bootstrap.Client/Tasks/DeployTaskManager.cs
deleted file mode 100644
index 3cc742bd..00000000
--- a/src/client/Bootstrap.Client/Tasks/DeployTaskManager.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-using Bootstrap.Client.Controllers.Api;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Concurrent;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace Bootstrap.Client.Tasks
-{
- ///
- /// 发布任务管理操作类
- ///
- public static class DeployTaskManager
- {
- private static BlockingCollection _pool = new BlockingCollection(new ConcurrentQueue());
- private static IServiceCollection? _services;
-
- ///
- /// IServiceCollection 实例
- ///
- ///
- internal static void RegisterServices(IServiceCollection services) => _services = services;
-
- ///
- /// 添加自动发布任务到队列中
- ///
- ///
- public static void Add(GiteePushEventArgs args)
- {
- // 判断是否需要自动发布
- if (_services != null)
- {
- var sp = _services.BuildServiceProvider();
- var config = sp.GetRequiredService();
- var logger = sp.GetRequiredService>();
- var option = config.GetSection().Get();
- if (option.Enabled && !string.IsNullOrEmpty(option.DeployFile))
- {
- if (!_pool.IsAddingCompleted)
- {
- _pool.Add(args);
- }
-
- RunAsync(logger, option).ConfigureAwait(false);
- }
- }
- }
-
- private static bool _running;
- private static object _locker = new object();
-
- private static async Task RunAsync(ILogger logger, DeployOptions options)
- {
- if (!_running)
- {
- await Task.Run(() =>
- {
- // 线程等待防止多个部署任务同时执行
- lock (_locker)
- {
- if (!_running)
- {
- _running = true;
- while (_pool.TryTake(out var args))
- {
- // 分析提交分支
- if (args.Ref.SpanSplit("/").LastOrDefault().Equals(options.Branch, StringComparison.OrdinalIgnoreCase) && CanDeploy(options.OSPlatform))
- {
- // 仅部署配置分支代码
- Deploy(logger, options.DeployFile);
- }
- }
- }
- }
- _running = false;
- });
- }
- }
-
- private static bool CanDeploy(string osPlatform)
- {
- var os = OSPlatform.Create(osPlatform);
- return !RuntimeInformation.IsOSPlatform(os);
- }
-
- private static void Deploy(ILogger logger, string deployFile)
- {
- // 调用部署脚本
- try
- {
- //var psi = new ProcessStartInfo("sh", "~/BootstrapAdmin/deploy-admin.sh");
- var cmd = deployFile;
- if (File.Exists(cmd))
- {
- var psi = new ProcessStartInfo("sh", $"\"{cmd}\"");
- psi.RedirectStandardOutput = true;
- psi.UseShellExecute = false;
- var p = Process.Start(psi);
- p.WaitForExit();
- var result = p.StandardOutput.ReadToEnd();
- logger.LogError("deploy success: {0}", result);
- }
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "");
- }
- }
- }
-}
diff --git a/src/client/Bootstrap.Client/appsettings.Development.json b/src/client/Bootstrap.Client/appsettings.Development.json
index 016b5bea..9e8fe519 100644
--- a/src/client/Bootstrap.Client/appsettings.Development.json
+++ b/src/client/Bootstrap.Client/appsettings.Development.json
@@ -52,12 +52,6 @@
"From": "honeywell_mes@163.com",
"To": "argo@163.com"
},
- "DeployOptions": {
- "Enabled": false,
- "DeployFile": "..\\..\\publish-admin.sh",
- "OSPlatform": "Windows",
- "Branch": "release"
- },
"AllowOrigins": "http://localhost:50852",
"LongbowCache": {
"Enabled": true,