import re from pydantic import BaseModel from scripts.common.cvs import GitRepository import os from fastapi import HTTPException from . import run_cmd class ProjectInfo(BaseModel): git_url: str base_dir: str = "/data/back_apps" host: str pre_script: str start_script: str name: str async def deploy_service(project: ProjectInfo, tag: str): # git clone local_path = project.base_dir+'/'+tag #print(local_path, project.git_url, tag) git = GitRepository(local_path=local_path, repo_url=project.git_url) git.pull() git.change_to_tag(tag) # run pre scripts run_cmd(project.pre_script) # find tag files pass # run ansible-play deloy tag files && run start script in remote