a production-ready node.js app that receives github webhook events and sends formatted notifications to a telegram chat
- real-time notifications: receives github webhooks and sends immediate telegram notifications
- secure webhook validation: hmac-sha256 signature validation for github webhooks
- event deduplication: prevents duplicate notifications for the same event
- rate limiting: respects telegram api rate limits (30 messages/second)
- comprehensive logging: structured logging with winston for debugging and monitoring
- docker support: ready for containerized deployment
- health monitoring: built-in health check endpoint
currently supports push events with comprehensive parsing for:
- branch information
- commit details and messages
- file changes (added, modified, removed)
- author information
- repository links
note: the parser also handles pull requests, issues, and ci events, but only push events are currently forwarded to telegram.
- node.js 18+ or docker
- a telegram bot token (from @botfather)
- a telegram chat id where notifications will be sent
- a github repository with webhook access
-
clone the repository
git clone https://github.com/tacbuild/git-watcher.git cd git-watcher
-
install dependencies
npm install
-
set up environment variables
cp .env.example .env # edit .env with your configuration
-
build the application
npm run build
-
start the application
npm start
-
build the docker image
docker build -t git-watcher .
-
run with docker compose
docker-compose up -d
variable | description | required | default |
---|---|---|---|
port |
port for the http server | no | 3000 |
node_env |
environment (development/production) | no | development |
log_level |
logging level (error/warn/info/debug) | no | info |
telegram_bot_token |
your telegram bot token | yes | - |
telegram_chat_id |
target chat id for notifications | yes | - |
github_webhook_secret |
secret for webhook signature validation | yes | - |
- message @botfather on telegram
- send
/newbot
and follow the instructions - save the bot token provided
- add your bot to the target chat/group
- send a message to the chat
- visit
https://api.telegram.org/bot<your_bot_token>/getupdates
- find your chat id in the response
- go to your github repository settings
- navigate to "webhooks" → "add webhook"
- set payload url to:
https://your-domain.com/webhook
- set content type to:
application/json
- generate a secret and add it to your
.env
file - select "send me everything" or choose specific events
- ensure the webhook is active
- start the application
- visit
http://localhost:3000/health
to check if it's running - visit
http://localhost:3000/test-telegram
to test telegram connectivity - push to your github repository to test the webhook
endpoint | method | description |
---|---|---|
/health |
get | health check endpoint |
/test-telegram |
get | test telegram bot connectivity |
/webhook |
post | github webhook receiver |
npm run build
- build the typescript codenpm run dev
- start development server with hot reloadnpm start
- start production servernpm run lint
- run eslintnpm run lint:fix
- fix eslint issuesnpm run format
- format code with prettiernpm run format:check
- check code formatting
├── controllers/ # http request handlers
├── middleware/ # express middleware
├── services/ # business logic services
├── types/ # typescript type definitions
├── utils/ # utility functions
└── index.ts # main application entry point
the application includes a multi-stage dockerfile optimized for production:
# build and run with docker
docker build -t git-watcher .
docker run -p 3000:3000 --env-file .env git-watcher
# start the service
docker-compose up -d
# check logs
docker-compose logs -f
# stop the service
docker-compose down
the application provides structured logging and health monitoring:
- health check:
get /health
returns application status and cache statistics - logs: written to
logs/
directory with rotation - metrics: request duration, event processing status, telegram api calls