diff --git a/EMAIL_AUTOMATION_GUIDE.md b/EMAIL_AUTOMATION_GUIDE.md index 98840fb..b3efd39 100644 --- a/EMAIL_AUTOMATION_GUIDE.md +++ b/EMAIL_AUTOMATION_GUIDE.md @@ -50,14 +50,15 @@ If your VPS uses the Webhook endpoint (`http://129.121.126.66:9000/hooks/deploy` npm run build systemctl restart springboot chatbot telegram-bot nginx - # 3. 📧 Send Email Report Notification + # 3. 📧 Send Email Report Notification (sent AFTER build & restart finish!) python3 /var/www/freshers-hub/scripts/send_git_email.py \ "$(git rev-parse --abbrev-ref HEAD)" \ "$(git log -1 --format='%an <%ae>')" \ "$(git log -1 --format='%h')" \ "$(git log -1 --format='%cd' --date=local)" \ "$(git log -1 --format='%B')" \ - "$(git diff-tree --no-commit-id --name-status -r HEAD | head -n 15)" + "$(git diff-tree --no-commit-id --name-status -r HEAD | head -n 15)" \ + "SUCCESS (LIVE ONLINE)" ) >> /var/log/deploy.log 2>&1 & diff --git a/scripts/send_git_email.py b/scripts/send_git_email.py index 5479562..62f6b27 100644 --- a/scripts/send_git_email.py +++ b/scripts/send_git_email.py @@ -16,7 +16,7 @@ SENDER_PASSWORD = os.environ.get("SENDER_PASSWORD", "qkwylwtcsnlrpree").replace( RECIPIENT_EMAIL = os.environ.get("RECIPIENT_EMAIL", "dorutoslayer@gmail.com") if len(sys.argv) < 7: - print("Usage: python send_git_email.py ") + print("Usage: python send_git_email.py [deploy_status]") sys.exit(1) branch = sys.argv[1] @@ -25,8 +25,15 @@ commit_hash = sys.argv[3] timestamp = sys.argv[4] message = sys.argv[5] changed_files = sys.argv[6] +deploy_status = sys.argv[7] if len(sys.argv) > 7 else os.environ.get("DEPLOY_STATUS", "SUCCESS") -subject = f"[Freshers-Hub VPS] Code Push Report - Commit {commit_hash} ({branch})" +is_success = "SUCCESS" in deploy_status.upper() or "ONLINE" in deploy_status.upper() +status_bg = "#ecfdf5" if is_success else "#fef2f2" +status_border = "#10b981" if is_success else "#ef4444" +status_text = "#047857" if is_success else "#b91c1c" +status_icon = "✅" if is_success else "❌" + +subject = f"[Freshers-Hub VPS] {'🟢 ONLINE' if is_success else '🔴 FAILED'} - Deployment Report {commit_hash} ({branch})" html_content = f""" @@ -35,37 +42,61 @@ html_content = f"""
-
🚀 Freshers-Hub Deployment & Push Report
- +
+ 🚀 RIT Freshers-Hub CI/CD Report +
+ +
+ {status_icon} + Deployment Status: {deploy_status.upper()} +
+
Branch: {branch}
Author: {author}
Commit Hash: {commit_hash}
-
Time: {timestamp}
- +
Deployment Time: {timestamp}
+
Commit Message:
{message}
+
+ Verified Microservices Online: +
+ 🟢 springboot.service (Java API :8085)
+ 🟢 chatbot.service (Go AI Engine :8081)
+ 🟢 telegram-bot.service (Python Intermediary :8082)
+ 🟢 nginx.service (Web Server :80/:443) +
+
+
Changed Files (Top Modified):
{changed_files}
- + + +