run deployment on roles
All checks were successful
Deploy Containers / Prepare (push) Successful in 4s

This commit is contained in:
2025-10-08 21:49:00 -04:00
parent f92b77f320
commit 507703d662

View File

@@ -5,7 +5,7 @@ import subprocess
def git_diff(): def git_diff():
args = sys.argv args = sys.argv
res = subprocess.run(f"git diff --name-only {args[1]} {args[2]}", capture_output=True, shell=True, text=True) res = subprocess.run(f"git diff --name-only {args[1]} {args[2]}", capture_output=True, shell=True, text=True)
return [x for x in res.stdout.strip().split("\n") if "tasks/" in x and "roles/" not in x] return [x for x in res.stdout.strip().split("\n") if "tasks/" in x or "roles/" in x]
def construct_command(tag = None): def construct_command(tag = None):
command = f"ANSIBLE_CONFIG=ansible.cfg /usr/bin/ansible-playbook main.yml --vault-password-file ~/.vault_pass.txt --tags {tag}_deploy" command = f"ANSIBLE_CONFIG=ansible.cfg /usr/bin/ansible-playbook main.yml --vault-password-file ~/.vault_pass.txt --tags {tag}_deploy"
@@ -38,29 +38,33 @@ def main():
failed = [] failed = []
deployed = 0 deployed = 0
for file in diff: for file in diff:
if "tasks/" in file: # separating these for now because roles will typically
# separating these for now because roles will typically # have a bunch of other things tied to them
# have a bunch of other things tied to them if "roles/" not in file:
if "roles/" not in file: task_name = file.split("/")[1].split(".")[0]
task_name = file.split("/")[1].split(".")[0] task_file_path = os.path.join(tasks_path, file.split("/")[1])
task_file_path = os.path.join(tasks_path, file.split("/")[1])
if not os.path.exists(task_file_path): if not os.path.exists(task_file_path):
print(f"{task_name} doesn't exist, running cleanup") print(f"{task_name} doesn't exist, running cleanup")
res = subprocess.run(f"/usr/bin/docker container stop {task_name}", shell=True) res = subprocess.run(f"/usr/bin/docker container stop {task_name}", shell=True)
if res.returncode == 0: if res.returncode == 0:
subprocess.run(f"/usr/bin/docker container rm {task_name}", shell=True) subprocess.run(f"/usr/bin/docker container rm {task_name}", shell=True)
subprocess.run("/usr/bin/docker image prune -f", shell=True) subprocess.run("/usr/bin/docker image prune -f", shell=True)
subprocess.run("/usr/bin/docker container prune -f", shell=True) subprocess.run("/usr/bin/docker container prune -f", shell=True)
print(f"Cleaned up container {task_name}") print(f"Cleaned up container {task_name}")
# deploy the task, regardless of its status # deploy the task, regardless of its status
if "roles/" not in file:
task = deploy(task_name) task = deploy(task_name)
if not task: else:
failed.append(task_name) role_name = file.split("/")[1]
else: task = deploy(role_name)
deployed += 1
if not task:
failed.append(task_name)
else:
deployed += 1
if len(failed) <= 0 and deployed > 0: if len(failed) <= 0 and deployed > 0:
print("\n---------------------") print("\n---------------------")