Skip to content

âš“ Webhook

Webhook is a lightweight incoming webhook server that allows you to create HTTP endpoints (hooks) on your server, which you can use to execute configured commands.

Security Warning

The webhooks as configured in this repository are insecure. They do not currently implement signature verification (e.g., X-Hub-Signature) or authentication tokens. They should only be used in a trusted network environment or properly secured with a reverse proxy and authentication.

🛠 Installation

Debian/Ubuntu

apt install webhook

âš™ Configuration

Webhooks are defined in a JSON file (typically hooks.json). Each hook specifies an ID, the command to execute, and how to handle arguments.

Example hooks.json

[
  {
    "id": "rebuild-app",
    "execute-command": "/path/to/script.sh",
    "command-working-directory": "/path/to/wd",
    "pass-arguments-to-command": [
      { "source": "string", "name": "--option" },
      { "source": "string", "name": "value" }
    ]
  }
]

🚀 Service Setup

To run webhook as a background service, create a systemd unit file.

/etc/systemd/system/webhook.service

[Unit]
Description=Webhook Listener
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/path/to/working/dir
ExecStart=/usr/bin/webhook -hooks /path/to/hooks.json -verbose -port 9000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable Service

systemctl daemon-reload
systemctl enable --now webhook

🔗 References