Deploy to Cloudflare Workers with automatic deployment notifications
npm install wrangler-deploy-notifyDeploy to Cloudflare Workers with automatic deployment notifications. This package wraps wrangler deploy and sends deployment information to a notification service.
- 🚀 Wraps wrangler deploy with 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)
``bashGlobal installation
npm install -g wrangler-deploy-notify
Quick Start
$3
`bash
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-idDeploy with automatic notifications
wrangler-deploy-notify
`$3
`bash
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 production
`$3
The package also provides a shorter
wdn command:`bash
wdn --env production
`CLI Options
All standard
wrangler deploy options are supported, plus:| Option | Description |
|--------|-------------|
|
--notify-url | URL of the deployment notification service |
| --telegram-bot-token | Telegram bot token for notifications |
| --telegram-chat-id | Telegram chat ID for notifications |
| --skip-notification | Skip sending notification |
| --project-name | Override project name detection |
| --tag | Add a tag to the deployment |
| --verbose | Show verbose output |$3
| Option | Description |
|--------|-------------|
|
--env | Environment to deploy to |
| --dry-run | Build but don't deploy |
| --compatibility-date | Compatibility date |
| --compatibility-flags | Compatibility flags (repeatable) |
| --config | Path to wrangler config file |
| --var | Variables to pass to deployment |Programmatic Usage
`javascript
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:`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
`yaml
name: Deployon:
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 production
`What 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:
`json
{
"deployment": {
"type": "worker",
"projectName": "my-api",
"deploymentId": "deploy-1234567890",
"branch": "main",
"commitHash": "abc123def456789...",
"commitMessage": "Add user authentication\n\nImplemented JWT tokens...",
"author": "dev@example.com",
"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
$3
| 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) |$3
The package automatically detects:
- Project name from (in order):
1.
--project-name argument
2. package.json name field
3. wrangler.toml name field
4. CLOUDFLARE_PROJECT_NAME env var- Git information using git commands
- CI environment from
CI or WORKERS_CI` env vars- 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
MIT