自动部署(无分支无commit)
(config)
| 104 | os.remove(script_file) |
| 105 | |
| 106 | def 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 | |
| 139 | def manual_branch_deploy(config, manual_branch): |
| 140 | """手动分支部署(有分支)""" |
no test coverage detected