MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / auto_deploy

Function auto_deploy

mod/project/git/scripts/deploy.py:106–137  ·  view source on GitHub ↗

自动部署(无分支无commit)

(config)

Source from the content-addressed store, hash-verified

104 os.remove(script_file)
105
106def auto_deploy(config):
107 """自动部署(无分支无commit)"""
108 site_name = config.get('type_parm')
109 config_branch = config.get('branch', 'main')
110 deploy_script = config.get('deploy_script', '')
111
112 log(f"自动部署: {site_name} -> {config_branch}")
113
114 # 获取网站信息
115 site_info = get_site_info(site_name)
116 if not site_info:
117 return False, "网站不存在或不是Git仓库"
118
119 site_path = site_info['path']
120 display_git_info(site_path)
121
122 # 拉取代码
123 if not run_cmd(f"cd {site_path} && git pull origin {config_branch}"):
124 return False, "代码拉取失败"
125
126 log("🚀 仓库成功部署!")
127
128 # 执行部署脚本
129 success, error_msg = execute_deploy_script(site_path, deploy_script)
130 if not success:
131 return False, error_msg
132
133 # 修正权限
134 run_cmd(f"chown -R www:www {site_path}")
135 log("部署完成", "✅")
136
137 return True, ""
138
139def manual_branch_deploy(config, manual_branch):
140 """手动分支部署(有分支)"""

Callers 1

execute_deploymentFunction · 0.85

Calls 6

get_site_infoFunction · 0.85
display_git_infoFunction · 0.85
execute_deploy_scriptFunction · 0.85
logFunction · 0.70
run_cmdFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected