From d400e94d16cf54bd0268758973be64bbae26badf Mon Sep 17 00:00:00 2001 From: "Developer @ Loverde Company" Date: Fri, 11 Sep 2026 14:36:50 -0300 Subject: [PATCH] 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. --- .gitea/workflows/beta.yml | 25 +++++++++++++++++++++++++ .gitea/workflows/test.yml | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/.gitea/workflows/beta.yml b/.gitea/workflows/beta.yml index 89cee88..9ebbf07 100644 --- a/.gitea/workflows/beta.yml +++ b/.gitea/workflows/beta.yml @@ -52,3 +52,28 @@ jobs: - name: Clean up API key if: always() run: rm -f fastlane/apikey.json + + - 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 diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index f0e04d0..c6265da 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -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