执行部署脚本
(site_path, deploy_script)
| 84 | pass |
| 85 | |
| 86 | def execute_deploy_script(site_path, deploy_script): |
| 87 | """执行部署脚本""" |
| 88 | if not deploy_script: |
| 89 | return True, "" |
| 90 | |
| 91 | log("执行部署脚本...") |
| 92 | script_file = f"/tmp/deploy_{int(time.time())}.sh" |
| 93 | try: |
| 94 | with open(script_file, 'w') as f: |
| 95 | f.write(f"cd {site_path}\n{deploy_script}") |
| 96 | os.chmod(script_file, 0o755) |
| 97 | |
| 98 | if not run_cmd(f"bash {script_file}"): |
| 99 | return False, "部署脚本执行失败" |
| 100 | |
| 101 | return True, "" |
| 102 | finally: |
| 103 | if os.path.exists(script_file): |
| 104 | os.remove(script_file) |
| 105 | |
| 106 | def auto_deploy(config): |
| 107 | """自动部署(无分支无commit)""" |
no test coverage detected