wrangler-deploy-notify
v1.4.0
Published
Deploy to Cloudflare Workers with automatic deployment notifications
Downloads
9
Maintainers
Readme
wrangler-deploy-notify
Deploy to Cloudflare Workers with automatic deployment notifications. This package wraps wrangler deploy and sends deployment information to a notification service.
Features
- 🚀 Wraps
wrangler deploywith all its options - 📤 Sends deployment notifications with git information
- 🔧 Configurable via CLI arguments or environment variables
- 📦 Can be used as a CLI tool or programmatically
- 🎯 Automatic git information extraction
- ⚡ Zero configuration needed (uses env vars)
Installation
# Global installation
npm install -g wrangler-deploy-notify
# Or as a dev dependency
npm install --save-dev wrangler-deploy-notifyQuick Start
Using Environment Variables
# Set up once
export DEPLOY_NOTIFY_URL=https://deploy-notify.your-domain.workers.dev
export TELEGRAM_BOT_TOKEN=your-telegram-bot-token
export TELEGRAM_CHAT_ID=your-telegram-chat-id
# Deploy with automatic notifications
wrangler-deploy-notifyUsing CLI Arguments
wrangler-deploy-notify \
--notify-url https://deploy-notify.your-domain.workers.dev \
--telegram-bot-token your-telegram-bot-token \
--telegram-chat-id your-telegram-chat-id \
--env productionShort Command Alias
The package also provides a shorter wdn command:
wdn --env productionCLI Options
All standard wrangler deploy options are supported, plus:
| Option | Description |
|--------|-------------|
| --notify-url <url> | URL of the deployment notification service |
| --telegram-bot-token <token> | Telegram bot token for notifications |
| --telegram-chat-id <id> | Telegram chat ID for notifications |
| --skip-notification | Skip sending notification |
| --project-name <name> | Override project name detection |
| --tag <tag> | Add a tag to the deployment |
| --verbose | Show verbose output |
Wrangler Options
| Option | Description |
|--------|-------------|
| --env <environment> | Environment to deploy to |
| --dry-run | Build but don't deploy |
| --compatibility-date <date> | Compatibility date |
| --compatibility-flags <flag> | Compatibility flags (repeatable) |
| --config <path> | Path to wrangler config file |
| --var <key:value> | Variables to pass to deployment |
Programmatic Usage
import { deployWithNotification } from 'wrangler-deploy-notify';
await deployWithNotification({
notifyUrl: 'https://deploy-notify.your-domain.workers.dev',
telegramBotToken: 'your-telegram-bot-token',
telegramChatId: 'your-telegram-chat-id',
env: 'production',
vars: {
API_KEY: 'secret123',
DEBUG: 'true'
}
});Package.json Scripts
Add to your package.json:
{
"scripts": {
"deploy": "wrangler-deploy-notify",
"deploy:staging": "wrangler-deploy-notify --env staging",
"deploy:production": "wrangler-deploy-notify --env production --tag v$npm_package_version"
}
}GitHub Actions Example
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Deploy with notifications
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
DEPLOY_NOTIFY_URL: ${{ secrets.DEPLOY_NOTIFY_URL }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
run: npx wrangler-deploy-notify --env productionWhat Gets Sent
The notification includes:
- Project name (auto-detected from package.json or wrangler.toml)
- Git branch
- Git commit hash (full)
- Git commit message (full, including multi-line)
- Author email
- Timestamp
- Environment
- Tag (if specified)
- CI detection
Example notification payload:
{
"deployment": {
"type": "worker",
"projectName": "my-api",
"deploymentId": "deploy-1234567890",
"branch": "main",
"commitHash": "abc123def456789...",
"commitMessage": "Add user authentication\n\nImplemented JWT tokens...",
"author": "[email protected]",
"timestamp": "2025-01-15T10:30:00Z",
"environment": "production",
"tag": "v1.2.3",
"isCI": true,
"telegramBotToken": "your-telegram-bot-token",
"telegramChatId": "your-telegram-chat-id"
}
}Configuration
Environment Variables
| Variable | Description |
|----------|-------------|
| DEPLOY_NOTIFY_URL | Default notification service URL |
| TELEGRAM_BOT_TOKEN | Telegram bot token for notifications |
| TELEGRAM_CHAT_ID | Telegram chat ID for notifications |
| CLOUDFLARE_API_TOKEN | Cloudflare API token (for wrangler) |
Auto-Detection
The package automatically detects:
Project name from (in order):
--project-nameargumentpackage.jsonname fieldwrangler.tomlname fieldCLOUDFLARE_PROJECT_NAMEenv var
Git information using git commands
CI environment from
CIorWORKERS_CIenv vars
Error Handling
- Deployment failures will exit with code 1
- Notification failures will log a warning but won't fail the deployment
- Git detection failures will use fallback values
License
MIT
