This project listens for incoming webhook requests, matches the repository and branch from the payload with an API list, and triggers a deployment webhook for the matched application.
- Extracts the repository name and branch from the incoming payload.
- Fetches a list of applications from the Coolify API.
- Matches the repository and branch from the payload with the API list.
- Triggers a deployment webhook for the matched repository and branch.
This webhook handler is currently designed for Gitea and Gitea forks. Future plans include adding support for:
- GitLab
- GitHub
- Bitbucket
- Middleware hooks for push notifications, 2FA authorizations, and more.
- Bun (Bun runtime)
- A Coolify account and API credentials:
COOLIFY_API_URLCOOLIFY_API_KEY
- A secret key for securing webhooks (
WEBHOOKS_SECRET).
-
Clone the repository:
git clone https://github.com/premoweb/coolify-webhook-handler.git cd coolify-webhook-handler -
Install dependencies:
bun install
-
Create a
.envfile in the root of the project with the following variables:COOLIFY_API_URL=https://your-coolify-instance.com COOLIFY_API_KEY=your-coolify-api-key WEBHOOKS_SECRET=your-webhook-secret
Note:
WEBHOOKS_SECRETis a secret key used to secure the webhook. Keep it private and secure. -
Start the server:
bun run index.ts
The server will start on
http://localhost:3000.
-
In Coolify, create a new application and choose the Dockerfile option.
-
Set the port for the application to
3000to match the default port used by the webhook handler. -
Pick a subdomain or URL for your deployment, such as:
https://deployments.your-domain.com
-
Follow the prompts in Coolify to complete the deployment process.
-
Generate a strong secret key:
openssl rand -hex 32
-
Copy the generated key and add it to your
.envfile asWEBHOOKS_SECRET:WEBHOOKS_SECRET=your-generated-secret-key
-
Configure your webhook source (e.g., Gitea, GitHub) to use the same secret key when sending webhooks.
To test the webhook handler locally with curl, send the payload using the following command:
curl -X POST http://localhost:3000/ \
-H "Content-Type: application/json" \
-d @load.json- 200 OK: Deployment triggered successfully.
- 400 Bad Request: Invalid request (e.g., missing headers, invalid JSON).
- 404 Not Found: No matching repository and branch found.
- 500 Internal Server Error: Unexpected error.
This project is licensed under the MIT License.