This commit is contained in:
3
main.yml
3
main.yml
@@ -61,9 +61,6 @@
|
||||
- name: Deploy Immich
|
||||
import_tasks: tasks/immich.yml
|
||||
tags: immich_deploy
|
||||
- name: Deploy Jellyfin
|
||||
import_tasks: tasks/jellyfin.yml
|
||||
tags: jellyfin_deploy
|
||||
- name: Deploy Navidrome
|
||||
import_tasks: tasks/navidrome.yml
|
||||
tags: navidrome_deploy
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
bracket_regex = r'\[([^\]]*)\]'
|
||||
@@ -7,6 +8,7 @@ quote_regex = r'"([^"]*)"'
|
||||
|
||||
def git_diff():
|
||||
args = sys.argv
|
||||
print(args[1], args[2])
|
||||
res = subprocess.run(f"git diff --name-only {args[1]} {args[2]}", capture_output=True, shell=True, text=True)
|
||||
return res.stdout.strip().split("\n")
|
||||
|
||||
@@ -40,6 +42,7 @@ def run_deployment(tag = None):
|
||||
return success
|
||||
|
||||
def main():
|
||||
tasks_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../tasks")
|
||||
diff = git_diff()
|
||||
vpn_containers = [
|
||||
"tasks/qbittorrent.yml",
|
||||
@@ -58,6 +61,21 @@ def main():
|
||||
|
||||
for file in diff:
|
||||
if "tasks" in file:
|
||||
print(os.path.dirname(os.path.abspath(__file__)))
|
||||
if not os.path.exists(os.path.join(tasks_path, file.split("/")[1])):
|
||||
container_name = file.split("/")[1]
|
||||
print(f"file does not exist! attempting to remove docker container \"{container_name}\"..")
|
||||
|
||||
res = subprocess.run(f"docker container stop {container_name}")
|
||||
if res.returncode == 0:
|
||||
subprocess.run(f"docker container rm {container_name}")
|
||||
subprocess.run(f"docker image prune -f")
|
||||
subprocess.run(f"docker container prune -f")
|
||||
|
||||
print(f"successfully removed container \"{container_name}\"")
|
||||
else:
|
||||
print(f"non-0 error code returned for stop command on container \"{container_name}\"")
|
||||
else:
|
||||
task_name = file.split("/")[1].split(".")[0] + "_deploy"
|
||||
state = run_deployment(tag=task_name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user