From 0fa42b1b2c289cfc2e51ee2f078bea31e88b861c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Fri, 9 Jan 2026 18:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E5=85=8B=E9=9A=86?= =?UTF-8?q?=E5=88=B0=20runtime/a-cloud-all=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devops/deployer.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/.devops/deployer.py b/.devops/deployer.py index fbdc0e1..da4e15e 100644 --- a/.devops/deployer.py +++ b/.devops/deployer.py @@ -68,24 +68,19 @@ class Deployer: def ensure_main_repo(self): """确保主仓库存在并是最新的""" - # 直接使用 runtime_path 作为仓库路径 - repo_path = self.runtime_path + # 克隆到 runtime/a-cloud-all 目录 + repo_path = self.runtime_path / 'a-cloud-all' # 检查是否是有效的 Git 仓库 if not (repo_path / '.git').exists(): self.logger.info("主仓库不存在,开始克隆...") - # 如果目录存在但不是 Git 仓库,先删除 - if repo_path.exists(): - self.logger.warning(f"目录 {repo_path} 已存在但不是 Git 仓库,将被删除") - shutil.rmtree(repo_path) + # 确保 runtime 目录存在 + self.runtime_path.mkdir(parents=True, exist_ok=True) - # 确保父目录存在 - repo_path.parent.mkdir(parents=True, exist_ok=True) - - # 克隆到 runtime 目录 - cmd = f"git clone --recurse-submodules {self.main_repo_url} {repo_path}" - if not self.run_command(cmd, cwd=repo_path.parent): + # 克隆到 runtime/a-cloud-all 目录 + cmd = f"git clone --recurse-submodules {self.main_repo_url} a-cloud-all" + if not self.run_command(cmd, cwd=self.runtime_path): self.logger.error("克隆主仓库失败") return False @@ -111,7 +106,7 @@ class Deployer: def update_submodule(self, repo_config): """更新指定的子模块""" - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' submodule_path = repo_path / repo_config['path'] self.logger.info(f"更新子模块: {repo_config['name']}") @@ -135,7 +130,7 @@ class Deployer: def build_project(self, repo_config): """构建项目""" - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' submodule_path = repo_path / repo_config['path'] self.logger.info(f"开始构建: {repo_config['name']}") @@ -152,7 +147,7 @@ class Deployer: def copy_artifacts(self, repo_config): """复制构建产物到 docker 目录""" - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' submodule_path = repo_path / repo_config['path'] self.logger.info(f"复制构建产物: {repo_config['name']}") @@ -193,7 +188,7 @@ class Deployer: def run_deploy_script(self, repo_config): """执行部署脚本""" - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' script_name = repo_config['deploy_script'] script_path = repo_path / '.devops' / 'scripts' / script_name @@ -223,7 +218,7 @@ class Deployer: self.logger.info("自动提交已禁用,跳过") return True - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' self.logger.info("提交子模块更新到主仓库") @@ -306,7 +301,7 @@ class Deployer: if 'infrastructure' not in self.config: return True - repo_path = self.runtime_path + repo_path = self.runtime_path / 'a-cloud-all' for infra in self.config['infrastructure']: name = infra['name']