From dd4ce573884e31811d14fbc8498f46ffe6af2e96 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 17:56:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E5=BE=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9A=E7=9B=B4=E6=8E=A5=E5=85=8B=E9=9A=86=E5=88=B0?= =?UTF-8?q?=20runtime=20=E7=9B=AE=E5=BD=95=E8=80=8C=E4=B8=8D=E6=98=AF=20ru?= =?UTF-8?q?ntime/a-cloud-all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devops/deployer.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.devops/deployer.py b/.devops/deployer.py index 6ae8c2d..0fa1d78 100644 --- a/.devops/deployer.py +++ b/.devops/deployer.py @@ -68,21 +68,23 @@ class Deployer: def ensure_main_repo(self): """确保主仓库存在并是最新的""" - repo_path = self.runtime_path / 'a-cloud-all' + # 直接使用 runtime_path 作为仓库路径 + repo_path = self.runtime_path - if not repo_path.exists(): + if not repo_path.exists() or not (repo_path / '.git').exists(): self.logger.info("主仓库不存在,开始克隆...") - 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=self.runtime_path): + if not self.run_command(cmd, cwd=repo_path.parent): self.logger.error("克隆主仓库失败") return False self.logger.info("主仓库克隆成功") else: self.logger.info("主仓库已存在,更新代码...") - + # 切换到指定分支 if not self.run_command(f"git checkout {self.main_repo_branch}", cwd=repo_path): return False @@ -101,7 +103,7 @@ class Deployer: def update_submodule(self, repo_config): """更新指定的子模块""" - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path submodule_path = repo_path / repo_config['path'] self.logger.info(f"更新子模块: {repo_config['name']}") @@ -125,7 +127,7 @@ class Deployer: def build_project(self, repo_config): """构建项目""" - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path submodule_path = repo_path / repo_config['path'] self.logger.info(f"开始构建: {repo_config['name']}") @@ -142,7 +144,7 @@ class Deployer: def copy_artifacts(self, repo_config): """复制构建产物到 docker 目录""" - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path submodule_path = repo_path / repo_config['path'] self.logger.info(f"复制构建产物: {repo_config['name']}") @@ -183,7 +185,7 @@ class Deployer: def run_deploy_script(self, repo_config): """执行部署脚本""" - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path script_name = repo_config['deploy_script'] script_path = repo_path / '.devops' / 'scripts' / script_name @@ -213,7 +215,7 @@ class Deployer: self.logger.info("自动提交已禁用,跳过") return True - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path self.logger.info("提交子模块更新到主仓库") @@ -296,7 +298,7 @@ class Deployer: if 'infrastructure' not in self.config: return True - repo_path = self.runtime_path / 'a-cloud-all' + repo_path = self.runtime_path for infra in self.config['infrastructure']: name = infra['name']