style(ci): send CI notification email as branded HTML, not plain text
Same as test.yml's Email notification step.
This commit is contained in:
@@ -61,16 +61,87 @@ jobs:
|
|||||||
NOTIFY_EMAIL_TO: ${{ secrets.NOTIFY_EMAIL_TO }}
|
NOTIFY_EMAIL_TO: ${{ secrets.NOTIFY_EMAIL_TO }}
|
||||||
run: |
|
run: |
|
||||||
STATUS="${{ job.status }}"
|
STATUS="${{ job.status }}"
|
||||||
SUBJECT="[PediFoods CI] ${STATUS} - ${{ github.workflow }}"
|
WORKFLOW="${{ github.workflow }}"
|
||||||
BODY="Job: ${{ github.workflow }} / ${{ github.job }}
|
JOB="${{ github.job }}"
|
||||||
Status: ${STATUS}
|
BRANCH="${{ github.ref_name }}"
|
||||||
Branch: ${{ github.ref_name }}
|
COMMIT="${{ github.sha }}"
|
||||||
Commit: ${{ github.sha }}
|
COMMIT_SHORT="${COMMIT:0:7}"
|
||||||
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||||
|
YEAR="$(date +%Y)"
|
||||||
|
|
||||||
printf 'From: PediFoods CI <%s>\r\nTo: %s\r\nSubject: %s\r\n\r\n%s\r\n' \
|
if [ "$STATUS" = "success" ]; then
|
||||||
"$SMTP_USER" "$NOTIFY_EMAIL_TO" "$SUBJECT" "$BODY" | \
|
BADGE_BG="#dcfce7"; BADGE_FG="#166534"; BADGE_LABEL="SUCESSO"; TITLE="Pipeline concluído com sucesso"
|
||||||
curl --silent --show-error \
|
else
|
||||||
|
BADGE_BG="#fee2e2"; BADGE_FG="#991b1b"; BADGE_LABEL="FALHA"; TITLE="Pipeline falhou"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SUBJECT="[PediFoods CI] ${BADGE_LABEL} - ${WORKFLOW}"
|
||||||
|
|
||||||
|
HTML_BODY=$(cat <<HTMLEOF
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>${SUBJECT}</title>
|
||||||
|
<style>
|
||||||
|
body { margin: 0; padding: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #f9fafb; color: #1f2937; }
|
||||||
|
.container { max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
|
||||||
|
.header { background-color: #111827; padding: 26px 20px; text-align: center; }
|
||||||
|
.header-title { color: #ffffff; font-size: 18px; font-weight: 700; margin: 0; }
|
||||||
|
.content { padding: 40px 30px; }
|
||||||
|
.footer { background-color: #f9fafb; padding: 30px 20px; text-align: center; font-size: 12px; color: #6b7280; border-top: 1px solid #e5e7eb; }
|
||||||
|
h1 { color: #111827; font-size: 22px; font-weight: 700; margin: 0 0 16px 0; text-align: center; }
|
||||||
|
.badge { display: inline-block; padding: 4px 14px; border-radius: 9999px; font-size: 12px; font-weight: 700; margin-bottom: 16px; background-color: ${BADGE_BG}; color: ${BADGE_FG}; }
|
||||||
|
.details { background-color: #f9fafb; padding: 20px; border-radius: 8px; margin: 20px 0; border: 1px solid #e5e7eb; }
|
||||||
|
.details-item { margin-bottom: 10px; font-size: 14px; display: flex; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
|
||||||
|
.details-item:last-child { border-bottom: none; margin-bottom: 0; }
|
||||||
|
.label { font-weight: 700; color: #374151; width: 110px; flex-shrink: 0; }
|
||||||
|
.value { color: #1f2937; word-break: break-all; }
|
||||||
|
.btn { display: inline-block; background-color: #111827; color: #ffffff !important; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 14px; margin: 10px 0; }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body { background-color: #111827; color: #f9fafb; }
|
||||||
|
.container { background-color: #1f2937; border: 1px solid #374151; box-shadow: none; }
|
||||||
|
.footer { background-color: #111827; border-top: 1px solid #374151; color: #9ca3af; }
|
||||||
|
h1 { color: #ffffff; }
|
||||||
|
.details { background-color: #111827; border: 1px solid #374151; }
|
||||||
|
.details-item { border-bottom: 1px solid #374151; }
|
||||||
|
.label { color: #d1d5db; }
|
||||||
|
.value { color: #f3f4f6; }
|
||||||
|
.btn { background-color: #ffffff; color: #000000 !important; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header"><p class="header-title">🚀 Atomenta CI</p></div>
|
||||||
|
<div class="content">
|
||||||
|
<div style="text-align:center;"><span class="badge">${BADGE_LABEL}</span></div>
|
||||||
|
<h1>${TITLE}</h1>
|
||||||
|
<div class="details">
|
||||||
|
<div class="details-item"><span class="label">Workflow:</span><span class="value">${WORKFLOW}</span></div>
|
||||||
|
<div class="details-item"><span class="label">Job:</span><span class="value">${JOB}</span></div>
|
||||||
|
<div class="details-item"><span class="label">Branch:</span><span class="value">${BRANCH}</span></div>
|
||||||
|
<div class="details-item"><span class="label">Commit:</span><span class="value">${COMMIT_SHORT}</span></div>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:center;"><a href="${RUN_URL}" class="btn">Ver execução</a></div>
|
||||||
|
</div>
|
||||||
|
<div class="footer"><p>© ${YEAR} Atomenta</p></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
HTMLEOF
|
||||||
|
)
|
||||||
|
|
||||||
|
{
|
||||||
|
printf 'From: Atomenta CI <%s>\r\n' "$SMTP_USER"
|
||||||
|
printf 'To: %s\r\n' "$NOTIFY_EMAIL_TO"
|
||||||
|
printf 'Subject: %s\r\n' "$SUBJECT"
|
||||||
|
printf 'MIME-Version: 1.0\r\n'
|
||||||
|
printf 'Content-Type: text/html; charset=UTF-8\r\n'
|
||||||
|
printf '\r\n'
|
||||||
|
printf '%s\r\n' "$HTML_BODY"
|
||||||
|
} | curl --silent --show-error \
|
||||||
--url "smtp://mail.loverde.com.br:587" \
|
--url "smtp://mail.loverde.com.br:587" \
|
||||||
--ssl-reqd \
|
--ssl-reqd \
|
||||||
--mail-from "$SMTP_USER" \
|
--mail-from "$SMTP_USER" \
|
||||||
|
|||||||
Reference in New Issue
Block a user