修正:克隆到 runtime/a-cloud-all 目录

This commit is contained in:
孙小云 2026-01-09 18:16:34 +08:00
parent e56fb36ad3
commit 0fa42b1b2c
1 changed files with 13 additions and 18 deletions

View File

@ -68,24 +68,19 @@ class Deployer:
def ensure_main_repo(self): def ensure_main_repo(self):
"""确保主仓库存在并是最新的""" """确保主仓库存在并是最新的"""
# 直接使用 runtime_path 作为仓库路径 # 克隆到 runtime/a-cloud-all 目录
repo_path = self.runtime_path repo_path = self.runtime_path / 'a-cloud-all'
# 检查是否是有效的 Git 仓库 # 检查是否是有效的 Git 仓库
if not (repo_path / '.git').exists(): if not (repo_path / '.git').exists():
self.logger.info("主仓库不存在,开始克隆...") self.logger.info("主仓库不存在,开始克隆...")
# 如果目录存在但不是 Git 仓库,先删除 # 确保 runtime 目录存在
if repo_path.exists(): self.runtime_path.mkdir(parents=True, exist_ok=True)
self.logger.warning(f"目录 {repo_path} 已存在但不是 Git 仓库,将被删除")
shutil.rmtree(repo_path)
# 确保父目录存在 # 克隆到 runtime/a-cloud-all 目录
repo_path.parent.mkdir(parents=True, exist_ok=True) cmd = f"git clone --recurse-submodules {self.main_repo_url} a-cloud-all"
if not self.run_command(cmd, cwd=self.runtime_path):
# 克隆到 runtime 目录
cmd = f"git clone --recurse-submodules {self.main_repo_url} {repo_path}"
if not self.run_command(cmd, cwd=repo_path.parent):
self.logger.error("克隆主仓库失败") self.logger.error("克隆主仓库失败")
return False return False
@ -111,7 +106,7 @@ class Deployer:
def update_submodule(self, repo_config): 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'] submodule_path = repo_path / repo_config['path']
self.logger.info(f"更新子模块: {repo_config['name']}") self.logger.info(f"更新子模块: {repo_config['name']}")
@ -135,7 +130,7 @@ class Deployer:
def build_project(self, repo_config): 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'] submodule_path = repo_path / repo_config['path']
self.logger.info(f"开始构建: {repo_config['name']}") self.logger.info(f"开始构建: {repo_config['name']}")
@ -152,7 +147,7 @@ class Deployer:
def copy_artifacts(self, repo_config): def copy_artifacts(self, repo_config):
"""复制构建产物到 docker 目录""" """复制构建产物到 docker 目录"""
repo_path = self.runtime_path repo_path = self.runtime_path / 'a-cloud-all'
submodule_path = repo_path / repo_config['path'] submodule_path = repo_path / repo_config['path']
self.logger.info(f"复制构建产物: {repo_config['name']}") self.logger.info(f"复制构建产物: {repo_config['name']}")
@ -193,7 +188,7 @@ class Deployer:
def run_deploy_script(self, repo_config): 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_name = repo_config['deploy_script']
script_path = repo_path / '.devops' / 'scripts' / script_name script_path = repo_path / '.devops' / 'scripts' / script_name
@ -223,7 +218,7 @@ class Deployer:
self.logger.info("自动提交已禁用,跳过") self.logger.info("自动提交已禁用,跳过")
return True return True
repo_path = self.runtime_path repo_path = self.runtime_path / 'a-cloud-all'
self.logger.info("提交子模块更新到主仓库") self.logger.info("提交子模块更新到主仓库")
@ -306,7 +301,7 @@ class Deployer:
if 'infrastructure' not in self.config: if 'infrastructure' not in self.config:
return True return True
repo_path = self.runtime_path repo_path = self.runtime_path / 'a-cloud-all'
for infra in self.config['infrastructure']: for infra in self.config['infrastructure']:
name = infra['name'] name = infra['name']