#!/usr/bin/env python3 """Notif ntfy de déploiement: deploy-notify.py [detail] Tout en JSON vers la RACINE du serveur (headers HTTP = latin-1 → accents cassés en Title). Ne jamais bloquer un déploiement si ntfy est KO: erreurs sur stderr, exit 0.""" import json, sys, urllib.request app, ver, etat = sys.argv[1], sys.argv[2].lstrip("v"), sys.argv[3] detail = sys.argv[4] if len(sys.argv) > 4 else "" ok = etat == "ok" body = {"topic": "dev-notifs", "title": "Déploiement " + ("réussi" if ok else "en échec"), "message": f"{app}: {'déployé' if ok else 'ÉCHEC'} v{ver}" + (f" — {detail}" if detail else ""), "tags": ["white_check_mark" if ok else "rotating_light"], "priority": 3} req = urllib.request.Request("https://ntfy.dracodev.net/", data=json.dumps(body).encode(), headers={"Content-Type": "application/json", "User-Agent": "curl/8.0"}) try: urllib.request.urlopen(req, timeout=10).read() except Exception as e: print(f"ntfy indisponible: {e}", file=sys.stderr)