feat(ci): email notification on success or failure

Sends an email via the domain's own SMTP (mail.loverde.com.br:587,
STARTTLS) as the last step of both test.yml and beta.yml, using
if: always() so it fires regardless of the job's outcome - subject/body
include job.status, branch, commit and a link to the run. Credentials
(SMTP_USER, SMTP_PASS, NOTIFY_EMAIL_TO) come from repo/org secrets, not
hardcoded here.
This commit is contained in:
2026-09-11 14:36:50 -03:00
parent 55b65b874d
commit d400e94d16
2 changed files with 50 additions and 0 deletions

View File

@@ -24,3 +24,28 @@ jobs:
- name: Run tests with coverage
run: fastlane tests
- name: Email notification
if: always()
env:
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
NOTIFY_EMAIL_TO: ${{ secrets.NOTIFY_EMAIL_TO }}
run: |
STATUS="${{ job.status }}"
SUBJECT="[PediFoods CI] ${STATUS} - ${{ github.workflow }}"
BODY="Job: ${{ github.workflow }} / ${{ github.job }}
Status: ${STATUS}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
printf 'From: PediFoods CI <%s>\r\nTo: %s\r\nSubject: %s\r\n\r\n%s\r\n' \
"$SMTP_USER" "$NOTIFY_EMAIL_TO" "$SUBJECT" "$BODY" | \
curl --silent --show-error \
--url "smtp://mail.loverde.com.br:587" \
--ssl-reqd \
--mail-from "$SMTP_USER" \
--mail-rcpt "$NOTIFY_EMAIL_TO" \
--user "$SMTP_USER:$SMTP_PASS" \
--upload-file - || true