Official GitHub Action for sending email notifications via Elastic Email API v4 based on workflow outcomes.
- Easy Integration - Add email notifications to any workflow in minutes
- Status-Based Emails - Automatically format emails based on success/failure/cancelled status
- Multiple Recipients - Send notifications to multiple people at once using a comma-separated list
- Beautiful HTML Templates - Professional, responsive email templates out of the box
- Fully Customizable - Use custom email bodies or let the action generate them
- Fast & Reliable - Built on Node.js 20 with Elastic Email API v4
- Tested - Comprehensive test suite with 100% coverage
- Sign up for a free account at Elastic Email
- Navigate to Settings β API Keys
- Create a new API key with email sending permissions
- Copy your API key
- Go to your repository on GitHub
- Navigate to Settings β Secrets and variables β Actions
- Click New repository secret
- Name:
ELASTIC_EMAIL_API_KEY - Value: Paste your Elastic Email API key
- Click Add secret
name: CI with Email Notifications
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test
- name: Send failure notification
if: failure()
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: dev-team@example.com
subject: 'β Build Failed - ${{ github.repository }}'
status: failurename: Deploy with Notifications
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy application
id: deploy
run: ./deploy.sh
- name: Send deployment notification
if: always()
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: team@example.com
from_email: noreply@example.com
from_name: Deployment Bot
subject: 'Deployment ${{ job.status }} - ${{ github.repository }}'
status: ${{ job.status }}
body_type: HTML- name: Send custom notification
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: notifications@example.com
subject: Custom Alert
status: success
body_type: PlainText
body: |
Hello Team,
The workflow "${{ github.workflow }}" has completed successfully!
Repository: ${{ github.repository }}
Triggered by: ${{ github.actor }}
View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}| Input | Required | Default | Description |
|---|---|---|---|
api_key |
β Yes | - | Your Elastic Email API key (use GitHub Secrets) |
to |
Yes | - | Recipient email address(es). For multiple recipients, use a comma-separated list |
subject |
Yes | - | Email subject line |
status |
β Yes | - | Workflow status: success, failure, or cancelled |
body_type |
β No | HTML |
Email format: HTML or PlainText |
body |
β No | Auto-generated | Custom email body content |
from_email |
β No | Same as to |
Sender email (must be verified in Elastic Email) |
from_name |
β No | GitHub Actions |
Sender display name |
| Output | Description |
|---|---|
message_id |
Elastic Email transaction ID for the sent email |
- name: Send email
id: send_email
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: user@example.com
subject: Test
status: success
- name: Display message ID
run: echo "Email sent with ID: ${{ steps.send_email.outputs.message_id }}"- name: Success notification
if: success()
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: success@example.com
subject: 'β
Workflow Succeeded'
status: success- name: Failure notification
if: failure()
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: alerts@example.com
subject: 'β Workflow Failed - Immediate Action Required'
status: failure- name: Multi-recipient notification
if: always()
uses: elasticemail/elastic-email-action@v1
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: team@example.com, manager@example.com
subject: 'Build Status: ${{ job.status }}'
status: ${{ job.status }}- Node.js 20+
- act CLI (for local workflow testing)
npm install# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coveragenpm run buildThis creates a bundled dist/index.js file using @vercel/ncc.
- Create a test workflow file
.act/test-workflow.yml:
name: Test Email Action
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test email action
uses: ./
with:
api_key: ${{ secrets.ELASTIC_EMAIL_API_KEY }}
to: test@example.com
subject: Test Email
status: success- Run with act:
# Run without secrets (dry run)
act -W .act/test-workflow.yml
# Run with real API key
act -W .act/test-workflow.yml -s ELASTIC_EMAIL_API_KEY=your-api-key-hereProblem: The action returns a 401 error.
Solution:
- Verify your API key is correct in GitHub Secrets
- Ensure the API key has email sending permissions
- Check if the API key hasn't expired
Problem: Email address validation fails.
Solution:
- Ensure the
tofield contains a valid email address - Check for typos or extra spaces
- For multiple recipients, use comma separation:
email1@example.com, email2@example.com
Problem: Elastic Email rejects the sender address.
Solution:
- Verify your sender email in Elastic Email dashboard
- Don't specify
from_emailto use the recipient address as sender - Use a verified domain for sending
Problem: The action succeeds but email isn't received.
Solution:
- Check your spam/junk folder
- Verify the recipient email address is correct
- Check Elastic Email dashboard for delivery status using the
message_idoutput - Ensure your Elastic Email account has sufficient credits
Problem: GitHub Actions workflow fails during build verification.
Solution:
- Run
npm run buildlocally - Commit the updated
dist/index.jsfile - Push changes to your repository
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
npm test - Build:
npm run build - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Elastic Email Documentation
- Elastic Email API v4 Reference
- GitHub Actions Documentation
- Creating GitHub Actions
Made with β€οΈ by Elastic Email