opt: moderm message
This commit is contained in:
78
notify.sh
78
notify.sh
@@ -96,6 +96,15 @@ send_gmail() {
|
||||
status_text="FAILURE"
|
||||
fi
|
||||
|
||||
# Parse structured message data
|
||||
local branch=$(echo "$MESSAGE" | grep -oP '^Branch:\s*\K.*' || echo "")
|
||||
local commit=$(echo "$MESSAGE" | grep -oP '^Commit:\s*\K.*' || echo "")
|
||||
local commit_msg=$(echo "$MESSAGE" | grep -oP '^Message:\s*\K.*' || echo "")
|
||||
local actor=$(echo "$MESSAGE" | grep -oP '^Actor:\s*\K.*' || echo "")
|
||||
|
||||
# Shorten commit hash for display
|
||||
local commit_short="${commit:0:8}"
|
||||
|
||||
# Build modern HTML email with inline CSS
|
||||
local html_body=$(cat <<EOF
|
||||
<!DOCTYPE html>
|
||||
@@ -126,39 +135,72 @@ send_gmail() {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Title -->
|
||||
<!-- Repository Info -->
|
||||
<tr>
|
||||
<td style="padding: 0 40px 24px; text-align: center;">
|
||||
<h2 style="margin: 0; color: #111827; font-size: 24px; font-weight: 600;">$TITLE</h2>
|
||||
<h2 style="margin: 0; color: #111827; font-size: 20px; font-weight: 600;">${GITHUB_REPOSITORY:-Repository}</h2>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Message -->
|
||||
<!-- Deployment Details Cards -->
|
||||
<tr>
|
||||
<td style="padding: 0 40px 32px;">
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid $status_color; padding: 20px; border-radius: 6px;">
|
||||
<p style="margin: 0; color: #374151; font-size: 15px; line-height: 1.6; white-space: pre-wrap;">$MESSAGE</p>
|
||||
<table width="100%" cellpadding="0" cellspacing="0">
|
||||
<!-- Branch -->
|
||||
<tr>
|
||||
<td style="padding-bottom: 12px;">
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid #3b82f6; padding: 16px; border-radius: 6px;">
|
||||
<div style="color: #6b7280; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;">🌿 Branch</div>
|
||||
<div style="color: #111827; font-size: 15px; font-weight: 500; font-family: 'Courier New', monospace;">$branch</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Commit -->
|
||||
<tr>
|
||||
<td style="padding-bottom: 12px;">
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid #8b5cf6; padding: 16px; border-radius: 6px;">
|
||||
<div style="color: #6b7280; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;">🔖 Commit</div>
|
||||
<div style="color: #111827; font-size: 15px; font-weight: 500; font-family: 'Courier New', monospace;">$commit_short</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Commit Message -->
|
||||
<tr>
|
||||
<td style="padding-bottom: 12px;">
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid $status_color; padding: 16px; border-radius: 6px;">
|
||||
<div style="color: #6b7280; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;">💬 Commit Message</div>
|
||||
<div style="color: #111827; font-size: 15px; line-height: 1.5;">$commit_msg</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Actor -->
|
||||
<tr>
|
||||
<td>
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid #10b981; padding: 16px; border-radius: 6px;">
|
||||
<div style="color: #6b7280; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;">👤 Author</div>
|
||||
<div style="color: #111827; font-size: 15px; font-weight: 500;">$actor</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Metadata -->
|
||||
<tr>
|
||||
<td style="padding: 0 40px 32px;">
|
||||
<table width="100%" cellpadding="8" cellspacing="0" style="border-top: 1px solid #e5e7eb;">
|
||||
<table width="100%" cellpadding="8" cellspacing="0" style="border-top: 1px solid #e5e7eb; background-color: #fafafa; border-radius: 6px;">
|
||||
<tr>
|
||||
<td style="color: #6b7280; font-size: 13px; padding-top: 16px;">
|
||||
<strong>Repository:</strong> ${GITHUB_REPOSITORY:-N/A}
|
||||
<strong>🔢 Run ID:</strong> ${GITHUB_RUN_ID:-N/A}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="color: #6b7280; font-size: 13px;">
|
||||
<strong>Run ID:</strong> ${GITHUB_RUN_ID:-N/A}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="color: #6b7280; font-size: 13px;">
|
||||
<strong>Timestamp:</strong> $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
<strong>⏰ Timestamp:</strong> $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -168,8 +210,8 @@ send_gmail() {
|
||||
<!-- Action Button -->
|
||||
<tr>
|
||||
<td style="padding: 0 40px 40px; text-align: center;">
|
||||
<a href="$GIT_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" style="display: inline-block; background-color: #667eea; color: #ffffff; text-decoration: none; padding: 12px 32px; border-radius: 6px; font-weight: 600; font-size: 14px; transition: background-color 0.3s;">
|
||||
View Deployment Logs
|
||||
<a href="$GIT_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" style="display: inline-block; background-color: #667eea; color: #ffffff; text-decoration: none; padding: 14px 36px; border-radius: 8px; font-weight: 600; font-size: 15px; box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);">
|
||||
📋 View Deployment Logs
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -178,7 +220,7 @@ send_gmail() {
|
||||
<tr>
|
||||
<td style="background-color: #f9fafb; padding: 24px 40px; text-align: center; border-top: 1px solid #e5e7eb;">
|
||||
<p style="margin: 0; color: #9ca3af; font-size: 12px;">
|
||||
Automated deployment notification from <strong>${GITHUB_REPOSITORY:-Your Repository}</strong>
|
||||
🤖 Automated deployment notification from <strong>Act Runner</strong>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -203,6 +245,7 @@ Content-Type: multipart/alternative; boundary="$boundary"
|
||||
|
||||
--$boundary
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
$ICON $TITLE
|
||||
|
||||
@@ -217,6 +260,7 @@ View logs: $GIT_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
|
||||
|
||||
--$boundary
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
$html_body
|
||||
--$boundary--
|
||||
@@ -225,7 +269,7 @@ EOF
|
||||
|
||||
# Send email via SMTP
|
||||
echo -e " ${YELLOW}→${NC} Sending HTML email..."
|
||||
response=$(echo "$email_content" | curl --ssl-reqd \
|
||||
response=$(printf "%s" "$email_content" | curl --ssl-reqd \
|
||||
--url "smtp://smtp.gmail.com:587" \
|
||||
--user "$GMAIL_USER:$GMAIL_PASS" \
|
||||
--mail-from "$GMAIL_USER" \
|
||||
|
||||
Reference in New Issue
Block a user