An open API service indexing awesome lists of open source software.

https://github.com/asikur-dev/github-webhook-notifier-server

Automating GitHub Push Notifications to Discord - Streamline your development workflow by automatically sending GitHub push notifications to a Discord channel. This setup uses a Node.js server to process webhook events, extract key details like usernames and commit messages, and deliver customizable alerts with fallback options for robustness.
https://github.com/asikur-dev/github-webhook-notifier-server

asikur discord-push github github-actions push-notifications

Last synced: about 2 months ago
JSON representation

Automating GitHub Push Notifications to Discord - Streamline your development workflow by automatically sending GitHub push notifications to a Discord channel. This setup uses a Node.js server to process webhook events, extract key details like usernames and commit messages, and deliver customizable alerts with fallback options for robustness.

Awesome Lists containing this project

README

          

# GitHub to Discord Push Notification

An automated system to send GitHub **push event** notifications to a Discord channel using webhooks. Built with **Node.js**, this project listens to GitHub webhook payloads and sends customizable messages to keep your team updated in real-time.

---

## πŸš€ Features

* **Real-time notifications** for GitHub push events
* **Customizable messages** via query parameters
* **Robust fallbacks** for missing payload data
* **Easy to deploy** on platforms like Render
* **Support for multiple GitHub events** with extensibility

---

## πŸ”§ Prerequisites

* Node.js (>= 18.0.0)
* A Discord server with a webhook URL
* Access to a GitHub repository

---

## πŸ“¦ Installation

```bash
git clone
cd
npm install
```

---

## βš™οΈ Configuration

Create a `.env` file in the root:

```env
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-id/your-webhook-token
```

> ⚠️ Do **NOT** commit `.env` β€” add it to `.gitignore`

---

## πŸ–₯️ Running the Server Locally

```bash
npm start
```

### 🟒 Render Deployment

* Ensure your server listens to `process.env.PORT || 9000`
* Set `DISCORD_WEBHOOK_URL` in Render’s environment settings
* Deploy the project to Render

---

## πŸ”— GitHub Webhook Setup

1. Go to your GitHub repository β†’ **Settings** β†’ **Webhooks** β†’ **Add webhook**
2. **Payload URL**: `https://your-server.onrender.com/github-webhook`
3. **Content Type**: `application/json`
4. **Events to Trigger**: Select `Let me select individual events` and check `Pushes`
5. **Save** the webhook

---

## βš™οΈ How It Works

### Server Operation

* The server runs on `/github-webhook`
* Extracts commit data: username, repository name, commit message, URL
* Supports optional query string: `?message=` or `?data=` (default: `Asikur (default user)`)

### Discord Notification

* Sends message to `DISCORD_WEBHOOK_URL`
* Format:

```
Someone pushed to Unknown Repository: No commit message (No commit URL) - Custom note: Asikur (default user)
```

### Extending Support

* Add event handlers in `index.js` for other GitHub events (e.g., pull requests, issues, releases)
* Use `payload.action` or `payload` structure to customize the message

---

## 🎯 Benefits

* πŸ“‘ **Instant Updates**: Avoid manual status updates
* βš™οΈ **Efficient Workflow**: Streamlined team communication
* ✏️ **Custom Notes**: Add context with `?message=` or `?data=`
* πŸ”„ **Reliable Defaults**: Handles missing GitHub fields
* πŸ“’ **Scalable Integration**: Supports multiple channels or repositories

---

## πŸ“ˆ Use Cases

* πŸš€ Push to GitHub β†’ Auto notify on Discord
* πŸ”§ Pass custom notes with push using query parameters
* πŸ§‘β€πŸ’» Collaborate better with real-time updates

---

## πŸ§ͺ Troubleshooting

* **404 Error**: Ensure server is running and endpoint URL is correct
* **500 Error**: Check `DISCORD_WEBHOOK_URL` validity
* **No Notification**: Confirm GitHub webhook is active and push event is selected

---

## 🧩 Customizing Events

Go to **Webhook Settings β†’ Let me select individual events**:

* βœ… Pushes *(default implemented)*
* πŸ”ƒ Pull Requests
* 🐞 Issues
* πŸš€ Releases

Update `index.js` to parse and send messages for those events accordingly.

---

## 🀝 Contributing

Pull requests and issue reports are welcome!

---

## πŸ“œ License

This project is licensed under the **ISC License**.