From e4f845ef6ee73070e5bec2c548cb138173e07472 Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Fri, 24 Apr 2026 15:37:40 -0400 Subject: [PATCH] fix script, send discord notification --- .gitea/workflows/update.yml | 3 +++ scripts/run_updates.py | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/update.yml b/.gitea/workflows/update.yml index 119154a..984e26f 100644 --- a/.gitea/workflows/update.yml +++ b/.gitea/workflows/update.yml @@ -16,4 +16,7 @@ jobs: - name: Run update script run: | echo "${{ secrets.VAULT_PASS }}" > ~/.vault_pass.txt + python3 -m pip install requests yaml python3 scripts/run_updates.py + env: + UPDATES_DISCORD_WEBHOOK: ${{vars.UPDATES_DISCORD_WEBHOOK}} diff --git a/scripts/run_updates.py b/scripts/run_updates.py index 75ff6cf..30f85c7 100644 --- a/scripts/run_updates.py +++ b/scripts/run_updates.py @@ -3,6 +3,8 @@ import subprocess import os import yaml +DISCORD_WEBHOOK_URL = os.environ.get("UPDATES_DISCORD_WEBHOOK") + def search_for_image(image_name): tasks_folder = os.path.realpath(os.path.join('./', 'tasks')) if "library/" in image_name: @@ -33,7 +35,9 @@ def main(): continue if ":latest" not in reference: continue - + if image["result"] and not image["result"]["has_update"]: + continue + refs.append(reference) print("attempting to match images to references: " + ", ".join(refs)) @@ -57,5 +61,21 @@ def main(): else: print("All up to date! :)") + if DISCORD_WEBHOOK_URL: + print("sending discord notification..") + body = { + "username": "Homelab Updates", + "embeds": [ + { + "title": "Updated containers automatically!", + "description": f"Automatically redeployed containers recognized to need updates via Cup\n```{", ".join(deployable_tags)}```" + } + ] + } + headers = { + "content-type": "application/json" + } + requests.post(DISCORD_WEBHOOK_URL, json=body, headers=headers) + if __name__ == "__main__": main()