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']