CI/CD Integration
Use the Envloped CLI in CI/CD pipelines to send deployment notifications and transactional emails.
CI/CD Integration
The Envloped CLI is designed for automated environments. Use environment variables for authentication and --json/--quiet flags for machine-readable output.
Authentication
Set the ENVLOPED_API_KEY environment variable instead of running envloped login:
export ENVLOPED_API_KEY=en_your_api_key_here
envloped whoami # works without loginGitHub Actions
name: Deploy Notification
on:
push:
branches: [main]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Install Envloped CLI
run: curl -fsSL https://envloped.com/install.sh | bash
- name: Send deployment notification
env:
ENVLOPED_API_KEY: ${{ secrets.ENVLOPED_API_KEY }}
run: |
envloped send \
--from deploy@yourdomain.com \
--to team@yourdomain.com \
--subject "Deployed ${{ github.sha }}" \
--text "Branch ${{ github.ref_name }} deployed by ${{ github.actor }}"GitLab CI
deploy_notify:
stage: notify
image: alpine:latest
before_script:
- apk add --no-cache curl
- curl -fsSL https://envloped.com/install.sh | bash
- export PATH="$HOME/.local/bin:$PATH"
script:
- |
envloped send \
--from deploy@yourdomain.com \
--to team@yourdomain.com \
--subject "Deployed ${CI_COMMIT_SHORT_SHA}" \
--text "Pipeline ${CI_PIPELINE_ID} completed for ${CI_COMMIT_REF_NAME}"
variables:
ENVLOPED_API_KEY: $ENVLOPED_API_KEYJSON Stdin for Complex Emails
For more control, pipe a JSON payload via --stdin:
- name: Send HTML notification
env:
ENVLOPED_API_KEY: ${{ secrets.ENVLOPED_API_KEY }}
run: |
cat <<'EOF' | envloped send --stdin
{
"from": "deploy@yourdomain.com",
"to": "team@yourdomain.com",
"subject": "Build Report",
"html": "<h1>Build succeeded</h1><p>Commit: ${{ github.sha }}</p>"
}
EOFScripting with JSON Output
Use --json to parse output in scripts:
# Get the message ID from a sent email
MSG_ID=$(envloped send --from a@b.com --to c@d.com \
--subject "Test" --text "Hello" --json | jq -r '.messageId')
echo "Sent: $MSG_ID"
# List failed emails
envloped emails list --status failed --json | jq '.emails[].subject'Quiet Mode
Use --quiet when you only care about the exit code:
envloped send --from a@b.com --to c@d.com \
--subject "Alert" --text "System alert" --quiet
if [ $? -eq 0 ]; then
echo "Email sent"
else
echo "Failed to send"
fi