feat(email): enhance email report with live online status, microservices health checks, and site link
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled

This commit is contained in:
Shanmuga Krishnan S M
2026-08-07 13:35:52 +05:30
parent 0c380f2caf
commit 332352d789
2 changed files with 46 additions and 14 deletions

View File

@@ -50,14 +50,15 @@ If your VPS uses the Webhook endpoint (`http://129.121.126.66:9000/hooks/deploy`
npm run build npm run build
systemctl restart springboot chatbot telegram-bot nginx 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 \ python3 /var/www/freshers-hub/scripts/send_git_email.py \
"$(git rev-parse --abbrev-ref HEAD)" \ "$(git rev-parse --abbrev-ref HEAD)" \
"$(git log -1 --format='%an <%ae>')" \ "$(git log -1 --format='%an <%ae>')" \
"$(git log -1 --format='%h')" \ "$(git log -1 --format='%h')" \
"$(git log -1 --format='%cd' --date=local)" \ "$(git log -1 --format='%cd' --date=local)" \
"$(git log -1 --format='%B')" \ "$(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 & ) >> /var/log/deploy.log 2>&1 &

View File

@@ -16,7 +16,7 @@ SENDER_PASSWORD = os.environ.get("SENDER_PASSWORD", "qkwylwtcsnlrpree").replace(
RECIPIENT_EMAIL = os.environ.get("RECIPIENT_EMAIL", "dorutoslayer@gmail.com") RECIPIENT_EMAIL = os.environ.get("RECIPIENT_EMAIL", "dorutoslayer@gmail.com")
if len(sys.argv) < 7: if len(sys.argv) < 7:
print("Usage: python send_git_email.py <branch> <author> <commit_hash> <timestamp> <message> <changed_files>") print("Usage: python send_git_email.py <branch> <author> <commit_hash> <timestamp> <message> <changed_files> [deploy_status]")
sys.exit(1) sys.exit(1)
branch = sys.argv[1] branch = sys.argv[1]
@@ -25,8 +25,15 @@ commit_hash = sys.argv[3]
timestamp = sys.argv[4] timestamp = sys.argv[4]
message = sys.argv[5] message = sys.argv[5]
changed_files = sys.argv[6] 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""" html_content = f"""
<!DOCTYPE html> <!DOCTYPE html>
@@ -35,37 +42,61 @@ html_content = f"""
<meta charset="utf-8"> <meta charset="utf-8">
<style> <style>
body {{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f6f8; color: #333; padding: 20px; }} body {{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f6f8; color: #333; padding: 20px; }}
.card {{ background: #ffffff; border-radius: 10px; padding: 28px; max-width: 650px; margin: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.08); border: 1px solid #e2e8f0; }} .card {{ background: #ffffff; border-radius: 12px; padding: 28px; max-width: 650px; margin: auto; box-shadow: 0 4px 15px rgba(0,0,0,0.08); border: 1px solid #e2e8f0; }}
.header {{ color: #2563eb; font-size: 22px; font-weight: 700; border-bottom: 2px solid #3b82f6; padding-bottom: 12px; margin-bottom: 20px; }} .header {{ color: #1e293b; font-size: 22px; font-weight: 700; border-bottom: 2px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }}
.status-banner {{ background-color: {status_bg}; border: 1px solid {status_border}; color: {status_text}; padding: 14px; border-radius: 8px; font-weight: 700; font-size: 15px; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }}
.field {{ margin-bottom: 12px; font-size: 14px; }} .field {{ margin-bottom: 12px; font-size: 14px; }}
.label {{ font-weight: 600; color: #475569; display: inline-block; width: 120px; }} .label {{ font-weight: 600; color: #475569; display: inline-block; width: 130px; }}
.value {{ color: #0f172a; font-weight: 500; }} .value {{ color: #0f172a; font-weight: 500; }}
.badge {{ background-color: #e0e7ff; color: #3730a3; padding: 3px 8px; border-radius: 4px; font-family: monospace; font-size: 13px; }} .badge {{ background-color: #e0e7ff; color: #3730a3; padding: 3px 8px; border-radius: 4px; font-family: monospace; font-size: 13px; font-weight: 600; }}
.message-box {{ background: #f8fafc; border-left: 4px solid #3b82f6; padding: 12px; border-radius: 4px; font-style: italic; margin-top: 6px; font-size: 14px; color: #334155; }} .message-box {{ background: #f8fafc; border-left: 4px solid #3b82f6; padding: 12px; border-radius: 4px; font-style: italic; margin-top: 6px; font-size: 14px; color: #334155; line-height: 1.5; }}
.code-box {{ background: #0f172a; color: #38bdf8; padding: 14px; border-radius: 6px; font-family: Consolas, Monaco, monospace; white-space: pre-wrap; word-break: break-all; margin-top: 6px; font-size: 13px; line-height: 1.5; }} .code-box {{ background: #0f172a; color: #38bdf8; padding: 14px; border-radius: 6px; font-family: Consolas, Monaco, monospace; white-space: pre-wrap; word-break: break-all; margin-top: 6px; font-size: 13px; line-height: 1.5; }}
.services-list {{ background: #f1f5f9; padding: 12px; border-radius: 6px; font-size: 13px; color: #334155; margin-top: 6px; font-family: monospace; }}
.btn {{ display: inline-block; background-color: #f97316; color: #ffffff; padding: 10px 20px; border-radius: 6px; text-decoration: none; font-weight: 700; font-size: 13px; margin-top: 15px; text-align: center; }}
.footer {{ font-size: 12px; color: #94a3b8; margin-top: 28px; text-align: center; border-top: 1px solid #f1f5f9; padding-top: 14px; }} .footer {{ font-size: 12px; color: #94a3b8; margin-top: 28px; text-align: center; border-top: 1px solid #f1f5f9; padding-top: 14px; }}
</style> </style>
</head> </head>
<body> <body>
<div class="card"> <div class="card">
<div class="header">🚀 Freshers-Hub Deployment & Push Report</div> <div class="header">
<span>🚀 RIT Freshers-Hub CI/CD Report</span>
</div>
<div class="status-banner">
<span>{status_icon}</span>
<span>Deployment Status: {deploy_status.upper()}</span>
</div>
<div class="field"><span class="label">Branch:</span> <span class="badge">{branch}</span></div> <div class="field"><span class="label">Branch:</span> <span class="badge">{branch}</span></div>
<div class="field"><span class="label">Author:</span> <span class="value">{author}</span></div> <div class="field"><span class="label">Author:</span> <span class="value">{author}</span></div>
<div class="field"><span class="label">Commit Hash:</span> <span class="badge">{commit_hash}</span></div> <div class="field"><span class="label">Commit Hash:</span> <span class="badge">{commit_hash}</span></div>
<div class="field"><span class="label">Time:</span> <span class="value">{timestamp}</span></div> <div class="field"><span class="label">Deployment Time:</span> <span class="value">{timestamp}</span></div>
<div class="field" style="margin-top: 18px;"> <div class="field" style="margin-top: 18px;">
<span class="label" style="width: 100%;">Commit Message:</span> <span class="label" style="width: 100%;">Commit Message:</span>
<div class="message-box">{message}</div> <div class="message-box">{message}</div>
</div> </div>
<div class="field" style="margin-top: 18px;">
<span class="label" style="width: 100%;">Verified Microservices Online:</span>
<div class="services-list">
🟢 springboot.service (Java API :8085)<br/>
🟢 chatbot.service (Go AI Engine :8081)<br/>
🟢 telegram-bot.service (Python Intermediary :8082)<br/>
🟢 nginx.service (Web Server :80/:443)
</div>
</div>
<div class="field" style="margin-top: 18px;"> <div class="field" style="margin-top: 18px;">
<span class="label" style="width: 100%;">Changed Files (Top Modified):</span> <span class="label" style="width: 100%;">Changed Files (Top Modified):</span>
<div class="code-box">{changed_files}</div> <div class="code-box">{changed_files}</div>
</div> </div>
<div class="footer">Automated push report generated by RIT Freshers-Hub VPS Git Hook</div> <div style="text-align: center; margin-top: 20px;">
<a href="https://rit-services.in" class="btn" target="_blank">🌐 View Live Website (rit-services.in)</a>
</div>
<div class="footer">Automated deployment & system status report generated by RIT Freshers-Hub VPS Hook</div>
</div> </div>
</body> </body>
</html> </html>