fix script, send discord notification
This commit is contained in:
@@ -16,4 +16,7 @@ jobs:
|
|||||||
- name: Run update script
|
- name: Run update script
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.VAULT_PASS }}" > ~/.vault_pass.txt
|
echo "${{ secrets.VAULT_PASS }}" > ~/.vault_pass.txt
|
||||||
|
python3 -m pip install requests yaml
|
||||||
python3 scripts/run_updates.py
|
python3 scripts/run_updates.py
|
||||||
|
env:
|
||||||
|
UPDATES_DISCORD_WEBHOOK: ${{vars.UPDATES_DISCORD_WEBHOOK}}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import subprocess
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
DISCORD_WEBHOOK_URL = os.environ.get("UPDATES_DISCORD_WEBHOOK")
|
||||||
|
|
||||||
def search_for_image(image_name):
|
def search_for_image(image_name):
|
||||||
tasks_folder = os.path.realpath(os.path.join('./', 'tasks'))
|
tasks_folder = os.path.realpath(os.path.join('./', 'tasks'))
|
||||||
if "library/" in image_name:
|
if "library/" in image_name:
|
||||||
@@ -33,6 +35,8 @@ def main():
|
|||||||
continue
|
continue
|
||||||
if ":latest" not in reference:
|
if ":latest" not in reference:
|
||||||
continue
|
continue
|
||||||
|
if image["result"] and not image["result"]["has_update"]:
|
||||||
|
continue
|
||||||
|
|
||||||
refs.append(reference)
|
refs.append(reference)
|
||||||
|
|
||||||
@@ -57,5 +61,21 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print("All up to date! :)")
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user