opt: moderm message

This commit is contained in:
2025-12-30 11:54:42 +07:00
parent b428b04fef
commit 783b920fa4

View File

@@ -96,6 +96,15 @@ send_gmail() {
status_text="FAILURE" status_text="FAILURE"
fi 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 # Build modern HTML email with inline CSS
local html_body=$(cat <<EOF local html_body=$(cat <<EOF
<!DOCTYPE html> <!DOCTYPE html>
@@ -126,39 +135,72 @@ send_gmail() {
</td> </td>
</tr> </tr>
<!-- Title --> <!-- Repository Info -->
<tr> <tr>
<td style="padding: 0 40px 24px; text-align: center;"> <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> </td>
</tr> </tr>
<!-- Message --> <!-- Deployment Details Cards -->
<tr> <tr>
<td style="padding: 0 40px 32px;"> <td style="padding: 0 40px 32px;">
<div style="background-color: #f9fafb; border-left: 4px solid $status_color; padding: 20px; border-radius: 6px;"> <table width="100%" cellpadding="0" cellspacing="0">
<p style="margin: 0; color: #374151; font-size: 15px; line-height: 1.6; white-space: pre-wrap;">$MESSAGE</p> <!-- 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> </div>
</td> </td>
</tr> </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 --> <!-- Metadata -->
<tr> <tr>
<td style="padding: 0 40px 32px;"> <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> <tr>
<td style="color: #6b7280; font-size: 13px; padding-top: 16px;"> <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> </td>
</tr> </tr>
<tr> <tr>
<td style="color: #6b7280; font-size: 13px;"> <td style="color: #6b7280; font-size: 13px;">
<strong>Run ID:</strong> ${GITHUB_RUN_ID:-N/A} <strong>⏰ Timestamp:</strong> $(date -u +"%Y-%m-%d %H:%M:%S UTC")
</td>
</tr>
<tr>
<td style="color: #6b7280; font-size: 13px;">
<strong>Timestamp:</strong> $(date -u +"%Y-%m-%d %H:%M:%S UTC")
</td> </td>
</tr> </tr>
</table> </table>
@@ -168,8 +210,8 @@ send_gmail() {
<!-- Action Button --> <!-- Action Button -->
<tr> <tr>
<td style="padding: 0 40px 40px; text-align: center;"> <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;"> <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 📋 View Deployment Logs
</a> </a>
</td> </td>
</tr> </tr>
@@ -178,7 +220,7 @@ send_gmail() {
<tr> <tr>
<td style="background-color: #f9fafb; padding: 24px 40px; text-align: center; border-top: 1px solid #e5e7eb;"> <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;"> <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> </p>
</td> </td>
</tr> </tr>
@@ -203,6 +245,7 @@ Content-Type: multipart/alternative; boundary="$boundary"
--$boundary --$boundary
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$ICON $TITLE $ICON $TITLE
@@ -217,6 +260,7 @@ View logs: $GIT_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
--$boundary --$boundary
Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
$html_body $html_body
--$boundary-- --$boundary--
@@ -225,7 +269,7 @@ EOF
# Send email via SMTP # Send email via SMTP
echo -e " ${YELLOW}${NC} Sending HTML email..." 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" \ --url "smtp://smtp.gmail.com:587" \
--user "$GMAIL_USER:$GMAIL_PASS" \ --user "$GMAIL_USER:$GMAIL_PASS" \
--mail-from "$GMAIL_USER" \ --mail-from "$GMAIL_USER" \