@@ -13,7 +13,7 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Run update script
|
- name: Configure credentials
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
|
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
|
||||||
@@ -21,8 +21,13 @@ jobs:
|
|||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add <(echo "${{ secrets.SSH_KEY }}")
|
ssh-add <(echo "${{ secrets.SSH_KEY }}")
|
||||||
echo "${{ secrets.VAULT_PASS }}" > ~/.vault_pass.txt
|
echo "${{ secrets.VAULT_PASS }}" > ~/.vault_pass.txt
|
||||||
|
|
||||||
|
- name: Install required dependencies
|
||||||
|
run: |
|
||||||
python3 -m pip install requests pyyaml ansible-core --break-system-packages
|
python3 -m pip install requests pyyaml ansible-core --break-system-packages
|
||||||
ansible-galaxy collection install community.docker
|
ansible-galaxy collection install community.docker
|
||||||
python3 scripts/run_updates.py
|
|
||||||
|
- name: Run update script
|
||||||
|
run: python3 scripts/run_updates.py
|
||||||
env:
|
env:
|
||||||
UPDATES_DISCORD_WEBHOOK: ${{vars.UPDATES_DISCORD_WEBHOOK}}
|
UPDATES_DISCORD_WEBHOOK: ${{vars.UPDATES_DISCORD_WEBHOOK}}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
import_tasks: tasks/utility/adguard.yml
|
import_tasks: tasks/utility/adguard.yml
|
||||||
tags: adguard_deploy
|
tags: adguard_deploy
|
||||||
- name: Deploy Glance
|
- name: Deploy Glance
|
||||||
import_tasks: tasks/glance.yml
|
import_tasks: tasks/utility/glance.yml
|
||||||
tags: glance_deploy
|
tags: glance_deploy
|
||||||
- name: Deploy Dozzle
|
- name: Deploy Dozzle
|
||||||
import_tasks: tasks/utility/dozzle.yml
|
import_tasks: tasks/utility/dozzle.yml
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
import_tasks: tasks/media/weatherstar.yml
|
import_tasks: tasks/media/weatherstar.yml
|
||||||
tags: weatherstar_deploy
|
tags: weatherstar_deploy
|
||||||
- name: Deploy Nextcloud
|
- name: Deploy Nextcloud
|
||||||
import_tasks: tasks/nextcloud.yml
|
import_tasks: tasks/utility/nextcloud.yml
|
||||||
tags: nextcloud_deploy
|
tags: nextcloud_deploy
|
||||||
|
|
||||||
- hosts: jackson
|
- hosts: jackson
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
import_tasks: tasks/cobalt.yml
|
import_tasks: tasks/cobalt.yml
|
||||||
tags: cobalt_deploy
|
tags: cobalt_deploy
|
||||||
- name: Deploy Nextcloud
|
- name: Deploy Nextcloud
|
||||||
import_tasks: tasks/nextcloud.yml
|
import_tasks: tasks/utility/nextcloud.yml
|
||||||
tags: nextcloud_deploy
|
tags: nextcloud_deploy
|
||||||
- name: Deploy Postgres
|
- name: Deploy Postgres
|
||||||
import_tasks: tasks/infra/postgres.yml
|
import_tasks: tasks/infra/postgres.yml
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
vpn_containers = [ # containers that need to be recreated re: vpn
|
# c08dc6b088e90512fb8a2dafe9f1ae5de3f486d1
|
||||||
"tasks/qbittorrent.yml",
|
# 894be8a440ba41aa228e53d7d523bcb1ae34da41
|
||||||
"tasks/jackett.yml"
|
|
||||||
]
|
|
||||||
ignore_deploys_for = [ # don't auto-deploy these
|
ignore_deploys_for = [ # don't auto-deploy these
|
||||||
"tasks/runner",
|
"tasks/runner",
|
||||||
"templates/runner",
|
"templates/runner",
|
||||||
@@ -19,7 +18,6 @@ def git_diff():
|
|||||||
|
|
||||||
def construct_command(tags):
|
def construct_command(tags):
|
||||||
command = f"ANSIBLE_CONFIG=ansible.cfg /usr/bin/ansible-playbook main.yml --tags={",".join(tags)} --vault-password-file ~/.vault_pass.txt"
|
command = f"ANSIBLE_CONFIG=ansible.cfg /usr/bin/ansible-playbook main.yml --tags={",".join(tags)} --vault-password-file ~/.vault_pass.txt"
|
||||||
print(command)
|
|
||||||
return command
|
return command
|
||||||
|
|
||||||
def deploy(tags):
|
def deploy(tags):
|
||||||
@@ -30,7 +28,11 @@ def deploy(tags):
|
|||||||
|
|
||||||
def get_normalized_task_name(container):
|
def get_normalized_task_name(container):
|
||||||
if "tasks/" in container:
|
if "tasks/" in container:
|
||||||
task_name = container.split("/")[1].split(".")[0]
|
split_path = container.split("/")
|
||||||
|
if len(split_path) > 2:
|
||||||
|
task_name = split_path[2].split(".")[0]
|
||||||
|
else:
|
||||||
|
task_name = split_path[1].split(".")[0]
|
||||||
elif "roles/" or "templates/" in container:
|
elif "roles/" or "templates/" in container:
|
||||||
task_name = container.split("/")[1]
|
task_name = container.split("/")[1]
|
||||||
else:
|
else:
|
||||||
@@ -51,8 +53,8 @@ def main():
|
|||||||
else:
|
else:
|
||||||
removable_containers.append(file)
|
removable_containers.append(file)
|
||||||
|
|
||||||
print(f"[MAIN] Deployable: {deployable_containers}")
|
print(f"[MAIN] Deployable: {len(deployable_containers)}")
|
||||||
print(f"[MAIN] Removable: {removable_containers}")
|
print(f"[MAIN] Removable: {len(removable_containers)}")
|
||||||
|
|
||||||
if len(deployable_containers) > 0:
|
if len(deployable_containers) > 0:
|
||||||
to_deploy = []
|
to_deploy = []
|
||||||
@@ -72,6 +74,7 @@ def main():
|
|||||||
shell=True,
|
shell=True,
|
||||||
capture_output=True
|
capture_output=True
|
||||||
)
|
)
|
||||||
|
result.check_returncode() # fail the action if this doesn't succeed
|
||||||
for line in result.stdout.splitlines():
|
for line in result.stdout.splitlines():
|
||||||
container_id = line.strip().decode("utf8")
|
container_id = line.strip().decode("utf8")
|
||||||
if not container_id:
|
if not container_id:
|
||||||
@@ -79,8 +82,8 @@ def main():
|
|||||||
print(f"[MAIN] Found Docker container {container_id} related to {task_name}, removing..")
|
print(f"[MAIN] Found Docker container {container_id} related to {task_name}, removing..")
|
||||||
subprocess.run(f"/usr/bin/docker container stop {container_id}", shell=True)
|
subprocess.run(f"/usr/bin/docker container stop {container_id}", shell=True)
|
||||||
subprocess.run(f"/usr/bin/docker container rm {container_id}", shell=True)
|
subprocess.run(f"/usr/bin/docker container rm {container_id}", shell=True)
|
||||||
subprocess.run("/usr/bin/docker image prune -f", shell=True)
|
subprocess.run("/usr/bin/docker image prune -af", shell=True)
|
||||||
subprocess.run("/usr/bin/docker container prune -f", shell=True)
|
subprocess.run("/usr/bin/docker container prune -af", shell=True)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
+10
-8
@@ -11,14 +11,16 @@ def search_for_image(image_name):
|
|||||||
image_name = image_name.replace("library/", "")
|
image_name = image_name.replace("library/", "")
|
||||||
image_name = image_name.split(":")[0]
|
image_name = image_name.split(":")[0]
|
||||||
|
|
||||||
for task in os.listdir(tasks_folder):
|
for category in os.listdir(tasks_folder):
|
||||||
with open(os.path.join(tasks_folder, task), 'r') as file:
|
tasks = os.listdir(os.path.join(tasks_folder, category))
|
||||||
data = yaml.safe_load(file)
|
for task in tasks:
|
||||||
|
with open(os.path.join(tasks_folder, category, task), 'r') as file:
|
||||||
|
data = yaml.safe_load(file)
|
||||||
|
|
||||||
for key in data:
|
for key in data:
|
||||||
if "vars" in key:
|
if "vars" in key:
|
||||||
if image_name in key["vars"]["image"]["name"] or image_name == key["vars"]["image"]["name"]:
|
if image_name in key["vars"]["image"]["name"] or image_name == key["vars"]["image"]["name"]:
|
||||||
return f"{task.split(".")[0]}_deploy"
|
return f"{task.split(".")[0]}_deploy"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
update_list = requests.get("https://cup.fntz.net/api/v3/json")
|
update_list = requests.get("https://cup.fntz.net/api/v3/json")
|
||||||
@@ -54,7 +56,7 @@ def main():
|
|||||||
subprocess.run(f'ANSIBLE_CONFIG=ansible.cfg ansible-playbook main.yml --tags {tag_string} -l bear --vault-password-file=~/.vault_pass.txt', shell=True)
|
subprocess.run(f'ANSIBLE_CONFIG=ansible.cfg ansible-playbook main.yml --tags {tag_string} -l bear --vault-password-file=~/.vault_pass.txt', shell=True)
|
||||||
|
|
||||||
print("Attempting to clean up dangling/unassumed images")
|
print("Attempting to clean up dangling/unassumed images")
|
||||||
subprocess.run(f"docker image prune -a -f", shell=True)
|
subprocess.run(f"docker image prune -af", shell=True)
|
||||||
|
|
||||||
print("Redeployed all images, refreshing Cup")
|
print("Redeployed all images, refreshing Cup")
|
||||||
requests.get("https://cup.fntz.net/api/v3/refresh")
|
requests.get("https://cup.fntz.net/api/v3/refresh")
|
||||||
|
|||||||
Reference in New Issue
Block a user