mirror of
https://github.com/Nezumi-2711/revanced-apk-build.git
synced 2026-09-22 05:32:07 +00:00
126 lines
5.2 KiB
YAML
126 lines
5.2 KiB
YAML
name: Email Notification Test
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
recipient_email:
|
|
description: 'Email address to send test to (leave empty to use MAIL_TO secret)'
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
send-test-email:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Send Test Email (Resend)
|
|
env:
|
|
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
|
|
MAIL_TO: ${{ inputs.recipient_email || secrets.MAIL_TO }}
|
|
MAIL_CC: ${{ secrets.MAIL_CC }}
|
|
MAIL_BCC: ${{ secrets.MAIL_BCC }}
|
|
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
|
run: |
|
|
if [ -z "$RESEND_API_KEY" ]; then
|
|
echo "❌ Error: RESEND_API_KEY secret is not set!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$MAIL_TO" ]; then
|
|
echo "❌ Error: No email recipient specified!"
|
|
echo "Either provide recipient_email input or set MAIL_TO secret."
|
|
exit 1
|
|
fi
|
|
|
|
# Set default FROM address if not provided
|
|
FROM_ADDRESS="${MAIL_FROM:-ReVanced Build Bot <onboarding@resend.dev>}"
|
|
|
|
VERSION="TEST-$(date +%Y%m%d-%H%M%S)"
|
|
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases"
|
|
REPO="${{ github.repository }}"
|
|
|
|
# Create test HTML email body
|
|
HTML_BODY=$(cat <<EOF
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
</head>
|
|
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 0;">
|
|
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center;">
|
|
<h1 style="margin: 0;">🧪 Test Email</h1>
|
|
<p style="margin: 10px 0 0 0; font-size: 18px;">Version: ${VERSION}</p>
|
|
</div>
|
|
<div style="padding: 25px; background: #f9f9f9;">
|
|
<div style="margin-bottom: 25px;">
|
|
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 10px 0;">✅ Email Configuration Working!</h2>
|
|
<p style="margin: 0;">Nếu bạn nhận được email này, nghĩa là cấu hình Resend đã hoạt động chính xác.</p>
|
|
</div>
|
|
<div style="margin-bottom: 25px;">
|
|
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 10px 0;">📋 Configuration Details</h2>
|
|
<ul style="list-style: none; padding: 0; margin: 0;">
|
|
<li>📧 From: ${FROM_ADDRESS}</li>
|
|
<li>📬 To: ${MAIL_TO}</li>
|
|
<li>🕐 Sent at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')</li>
|
|
</ul>
|
|
</div>
|
|
<div style="margin-bottom: 25px; text-align: center;">
|
|
<a href="${RELEASE_URL}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 30px; text-decoration: none; border-radius: 25px; font-weight: bold;">
|
|
View Releases
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div style="text-align: center; padding: 20px; background: #333; color: #999; font-size: 12px;">
|
|
<p style="margin: 0;">This is a TEST email from ReVanced Build Bot</p>
|
|
<p style="margin: 5px 0 0 0;">Repository: ${REPO}</p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
)
|
|
|
|
# Build JSON payload
|
|
JSON_PAYLOAD=$(jq -n \
|
|
--arg from "$FROM_ADDRESS" \
|
|
--arg to "$MAIL_TO" \
|
|
--arg cc "$MAIL_CC" \
|
|
--arg bcc "$MAIL_BCC" \
|
|
--arg subject "🧪 [TEST] ReVanced Build Email - ${VERSION}" \
|
|
--arg html "$HTML_BODY" \
|
|
'{
|
|
from: $from,
|
|
to: ($to | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; ""))),
|
|
subject: $subject,
|
|
html: $html
|
|
}
|
|
+ (if $cc != "" then {cc: ($cc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)
|
|
+ (if $bcc != "" then {bcc: ($bcc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)'
|
|
)
|
|
|
|
echo "📧 Sending test email to: $MAIL_TO"
|
|
if [ -n "$MAIL_CC" ]; then echo "📋 CC: $MAIL_CC"; fi
|
|
if [ -n "$MAIL_BCC" ]; then echo "🔒 BCC: $MAIL_BCC"; fi
|
|
echo ""
|
|
|
|
# Send email via Resend API
|
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://api.resend.com/emails" \
|
|
-H "Authorization: Bearer ${RESEND_API_KEY}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$JSON_PAYLOAD")
|
|
|
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
|
|
|
echo "Response: $BODY"
|
|
echo "HTTP Code: $HTTP_CODE"
|
|
|
|
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
|
echo ""
|
|
echo "✅ Test email sent successfully!"
|
|
echo "📬 Check your inbox at: $MAIL_TO"
|
|
else
|
|
echo ""
|
|
echo "❌ Failed to send email!"
|
|
echo "Please check your RESEND_API_KEY and email addresses."
|
|
exit 1
|
|
fi
|