Skip to content

Notify on CI Failure #239

Notify on CI Failure

Notify on CI Failure #239

name: Notify on CI Failure
on:
workflow_run:
workflows: ['CI']
types:
- completed
jobs:
notify:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
permissions:
contents: read
env:
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
TO_EMAIL: ${{ secrets.TO_EMAIL }}
steps:
- name: Skip if email secrets missing
if: ${{ env.RESEND_API_KEY == '' || env.TO_EMAIL == '' }}
run: |
echo "Resend disabled: secrets missing"
exit 0
- name: Send Resend email
env:
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
TO_EMAIL: ${{ secrets.TO_EMAIL }}
REPO: ${{ github.repository }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
run: |
payload=$(jq -n --arg to "$TO_EMAIL" \
--arg subject "[CI Failure] $REPO" \
--arg text "CI failed. Details: $RUN_URL" \
'{from:"[email protected]", to:[$to], subject:$subject, text:$text}')
curl -sfS https://api.resend.com/emails \
-H "Authorization: Bearer $RESEND_API_KEY" \
-H "Content-Type: application/json" \
-d "$payload"