mirror of
https://github.com/tubearchivist/tubearchivist-server.git
synced 2024-11-25 13:10:14 +00:00
implement build list of commands
This commit is contained in:
parent
d63e5bc407
commit
8124c63efb
@ -57,6 +57,15 @@ class Monitor(RedisBase):
|
|||||||
subprocess.run(base + ["use", "tubearchivist"], check=True)
|
subprocess.run(base + ["use", "tubearchivist"], check=True)
|
||||||
subprocess.run(base + ["inspect", "--bootstrap"], check=True)
|
subprocess.run(base + ["inspect", "--bootstrap"], check=True)
|
||||||
|
|
||||||
|
def check_stored(self):
|
||||||
|
"""check for any stored task since last watch"""
|
||||||
|
task = self.get_tasks()
|
||||||
|
if task["tasks"]:
|
||||||
|
print("found stored task:")
|
||||||
|
for task_name in task["tasks"]:
|
||||||
|
print(task_name)
|
||||||
|
Builder(task_name).run()
|
||||||
|
|
||||||
def watch(self):
|
def watch(self):
|
||||||
"""watch for messages"""
|
"""watch for messages"""
|
||||||
print("waiting for tasks")
|
print("waiting for tasks")
|
||||||
@ -110,13 +119,16 @@ class Builder(RedisBase):
|
|||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
"""build the container"""
|
"""build the container"""
|
||||||
if not self.task_detail["clone"]:
|
command_list = self.task_detail["build"]
|
||||||
build_command = self.task_detail["build"]
|
if all(isinstance(i, list) for i in command_list):
|
||||||
|
for command in command_list:
|
||||||
|
print(f"running: {command}")
|
||||||
|
subprocess.run(command, check=True)
|
||||||
else:
|
else:
|
||||||
build_command = ["docker", "buildx"] + self.task_detail["build"]
|
command = ["docker", "buildx"] + self.task_detail["build"]
|
||||||
build_command.append(os.path.join(self.CLONE_BASE, self.task))
|
command.append(os.path.join(self.CLONE_BASE, self.task))
|
||||||
|
print(f"running: {command}")
|
||||||
subprocess.run(build_command, check=True)
|
subprocess.run(command, check=True)
|
||||||
|
|
||||||
def remove_task(self):
|
def remove_task(self):
|
||||||
"""remove task from redis queue"""
|
"""remove task from redis queue"""
|
||||||
@ -127,6 +139,7 @@ class Builder(RedisBase):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
handler = Monitor()
|
handler = Monitor()
|
||||||
handler.bootstrap()
|
handler.bootstrap()
|
||||||
|
handler.check_stored()
|
||||||
try:
|
try:
|
||||||
handler.watch()
|
handler.watch()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -25,11 +25,11 @@ class WebhookBase:
|
|||||||
"-t", "bbilly1/tubearchivist:$VERSION", "--push"
|
"-t", "bbilly1/tubearchivist:$VERSION", "--push"
|
||||||
],
|
],
|
||||||
"sync_es": [
|
"sync_es": [
|
||||||
"docker", "image", "pull", "elasticsearch:$VERSION", "&&",
|
["docker", "image", "pull", "elasticsearch:$VERSION"],
|
||||||
"docker", "tag", "elasticsearch:$VERSION", "bbilly1/tubearchivist-es", "&&",
|
["docker", "tag", "elasticsearch:$VERSION", "bbilly1/tubearchivist-es"],
|
||||||
"docker", "tag", "elasticsearch:$VERSION", "bbilly1/tubearchivist-es:$VERSION", "&&",
|
["docker", "tag", "elasticsearch:$VERSION", "bbilly1/tubearchivist-es:$VERSION"],
|
||||||
"docker", "push", "bbilly1/tubearchivist-es", "&&",
|
["docker", "push", "bbilly1/tubearchivist-es"],
|
||||||
"docker", "push", "bbilly1/tubearchivist-es:$VERSION"
|
["docker", "push", "bbilly1/tubearchivist-es:$VERSION"],
|
||||||
],
|
],
|
||||||
"discord_unstable_hook": environ.get("DOCKER_UNSTABLE_HOOK_URL"),
|
"discord_unstable_hook": environ.get("DOCKER_UNSTABLE_HOOK_URL"),
|
||||||
"discord_release_hook": environ.get("GITHUB_RELEASE_HOOK_URL"),
|
"discord_release_hook": environ.get("GITHUB_RELEASE_HOOK_URL"),
|
||||||
|
@ -437,13 +437,20 @@ class TaskHandler(RedisBase):
|
|||||||
if not self.tag_name:
|
if not self.tag_name:
|
||||||
return self.repo_conf.get(task_name)
|
return self.repo_conf.get(task_name)
|
||||||
|
|
||||||
command = self.repo_conf.get(task_name)
|
all_commands = self.repo_conf.get(task_name)
|
||||||
for idx, command_part in enumerate(command):
|
|
||||||
if "$VERSION" in command_part:
|
|
||||||
subed = command_part.replace("$VERSION", self.tag_name)
|
|
||||||
command[idx] = subed
|
|
||||||
|
|
||||||
return command
|
if all(isinstance(i, list) for i in all_commands):
|
||||||
|
to_build_commands = []
|
||||||
|
for command in all_commands:
|
||||||
|
to_build_commands.append(self._replace_version(command))
|
||||||
|
else:
|
||||||
|
to_build_commands = self._replace_version(all_commands)
|
||||||
|
|
||||||
|
return to_build_commands
|
||||||
|
|
||||||
|
def _replace_version(self, command):
|
||||||
|
"""replace version in str"""
|
||||||
|
return [i.replace("$VERSION", self.tag_name) for i in command]
|
||||||
|
|
||||||
def set_pub(self):
|
def set_pub(self):
|
||||||
"""set message to pub"""
|
"""set message to pub"""
|
||||||
|
Loading…
Reference in New Issue
Block a user