optionally skip clone and call subprocess directly

This commit is contained in:
simon 2022-07-03 17:16:42 +07:00
parent 14cfbea287
commit d63e5bc407
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 12 additions and 2 deletions

View File

@ -95,6 +95,10 @@ class Builder(RedisBase):
def clone(self):
"""clone repo to destination"""
if not self.task_detail["clone"]:
print("skip clone")
return
print("clone repo")
repo_dir = os.path.join(self.CLONE_BASE, self.task_detail["name"])
if os.path.exists(repo_dir):
@ -106,8 +110,12 @@ class Builder(RedisBase):
def build(self):
"""build the container"""
build_command = ["docker", "buildx"] + self.task_detail["build"]
build_command.append(os.path.join(self.CLONE_BASE, self.task))
if not self.task_detail["clone"]:
build_command = self.task_detail["build"]
else:
build_command = ["docker", "buildx"] + self.task_detail["build"]
build_command.append(os.path.join(self.CLONE_BASE, self.task))
subprocess.run(build_command, check=True)
def remove_task(self):

View File

@ -427,6 +427,8 @@ class TaskHandler(RedisBase):
"name": self.repo_conf.get("gh_repo"),
"build": build_command,
}
if task_name == "sync_es":
task.update({"clone": False})
self.conn.json().set(self.key, f".tasks.{repo}", task)