Skip to content

The-Focus-AI/deployment-notification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Vercel Deployment Notification Function

This Supabase Edge Function receives webhook notifications from Vercel deployments and forwards them to a Telegram chat.

Setup Instructions

1. Deploy the Function to Supabase

# From your project root
cd supabase/functions
supabase functions deploy deployment-notification --no-verify-jwt

2. Create a Telegram Bot

  1. Open Telegram and search for "BotFather"
  2. Send /newbot and follow the instructions to create a new bot
  3. BotFather will give you a token - save this for later

3. Get Your Telegram Chat ID

  1. Add your bot to the desired chat/group
  2. Send a message in the chat
  3. Visit https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates in your browser
  4. Look for the chat object and note the id field - this is your chat ID

4. Set Environment Variables in Supabase

supabase secrets set TELEGRAM_BOT_TOKEN=<YOUR_BOT_TOKEN>
supabase secrets set TELEGRAM_CHAT_ID=<YOUR_CHAT_ID>
supabase secrets set WEBHOOK_SECRET=<YOUR_VERCEL_WEBHOOK_SECRET>

The WEBHOOK_SECRET is used to verify that the webhook is actually coming from Vercel. You can create this secret in your Vercel project settings when configuring the webhook.

5. Set Up the Vercel Webhook

  1. Go to your Vercel project settings
  2. Navigate to "Git Integration" > "Deploy Hooks"
  3. Add a new webhook with the URL: https://<PROJECT_REF>.supabase.co/functions/v1/deployment-notification

Testing

You can test the function by making a POST request that simulates a Vercel deployment webhook.

Current Vercel Webhook Format (2025):

curl -X POST https://<PROJECT_REF>.supabase.co/functions/v1/deployment-notification \
  -H "Content-Type: application/json" \
  -d '{
  "id": "dPUnTTNYPXi2-example",
  "payload": {
    "user": {
      "id": "user123"
    },
    "team": {
      "id": "team_123"
    },
    "deployment": {
      "id": "dpl_123",
      "meta": {
        "githubCommitAuthorName": "Developer Name",
        "githubCommitMessage": "Fix navigation bug",
        "githubCommitRef": "main",
        "githubCommitRepo": "upperhandai"
      },
      "name": "upperhandai",
      "url": "upperhandai-example.vercel.app",
      "inspectorUrl": "https://vercel.com/example/upperhandai/123"
    },
    "links": {
      "deployment": "https://vercel.com/example/upperhandai/123",
      "project": "https://vercel.com/example/upperhandai"
    },
    "name": "upperhandai",
    "plan": "pro",
    "project": {
      "id": "prj_123"
    },
    "regions": [
      "iad1"
    ],
    "target": "production",
    "type": "LAMBDAS",
    "url": "upperhandai-example.vercel.app"
  },
  "createdAt": 1741656811704,
  "type": "deployment.ready"
}'

Test a Deployment Error:

curl -X POST https://<PROJECT_REF>.supabase.co/functions/v1/deployment-notification \
  -H "Content-Type: application/json" \
  -d '{
  "id": "dPUnTTNYPXi2-example",
  "payload": {
    "deployment": {
      "id": "dpl_123",
      "meta": {
        "githubCommitAuthorName": "Developer Name",
        "githubCommitMessage": "Broken Build",
        "githubCommitRef": "feature/new-feature",
        "githubCommitRepo": "upperhandai"
      },
      "name": "upperhandai",
      "url": "upperhandai-example.vercel.app",
      "inspectorUrl": "https://vercel.com/example/upperhandai/123"
    },
    "name": "upperhandai",
    "target": "production",
    "url": "upperhandai-example.vercel.app"
  },
  "createdAt": 1741656811704,
  "type": "deployment.error"
}'

Vercel Webhook Format

The function is specifically designed to handle the Vercel webhook format currently used in 2025. The webhook payload contains:

  • id: A unique identifier for the webhook
  • payload: Contains all deployment information:
    • deployment: Details about the deployment including meta info with commit details
    • name: Project name
    • url: Deployment URL
    • target: Deployment target (production, preview, etc.)
  • createdAt: Timestamp of when the event occurred
  • type: Type of event (deployment.ready, deployment.error, etc.)

The function extracts this information and formats a helpful message for Telegram notifications.

About

Supabase Function that gets a vercel webhook and sends a telegram message

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published