랭킹으로 돌아가기

adnanh/webhook

Go

webhook is a lightweight incoming webhook server to run shell commands

webhookgodevopsdeployredeployshellwebserverincomingexecutehookhooks
스타 성장
스타
12k
포크
871
주간 성장
이슈
93
12k12k12k
7월 18일7월 19일7월 20일7월 21일
아티팩트Go Modulesgo get github.com/adnanh/webhook
README

What is webhook? build-status

Webhook

webhook is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands. You can also pass data from the HTTP request (such as headers, payload or query variables) to your commands. webhook also allows you to specify rules which have to be satisfied in order for the hook to be triggered.

For example, if you're using Github or Bitbucket, you can use webhook to set up a hook that runs a redeploy script for your project on your staging server, whenever you push changes to the master branch of your project.

If you use Mattermost or Slack, you can set up an "Outgoing webhook integration" or "Slash command" to run various commands on your server, which can then report back directly to you or your channels using the "Incoming webhook integrations", or the appropriate response body.

webhook aims to do nothing more than it should do, and that is:

  1. receive the request,
  2. parse the headers, payload and query variables,
  3. check if the specified rules for the hook are satisfied,
  4. and finally, pass the specified arguments to the specified command via command line arguments or via environment variables.

Everything else is the responsibility of the command's author.

Not what you're looking for?

hookdoo hookdeck
Scriptable webhook gateway to safely run your custom builds, deploys, and proxy scripts on your servers. An event gateway to reliably ingest, verify, queue, transform, filter, inspect, monitor, and replay webhooks.

Getting started

Installation

Building from source

To get started, first make sure you've properly set up your Go 1.21 or newer environment and then run

$ go build github.com/adnanh/webhook

to build the latest version of the webhook.

Using package manager

Snap store

Get it from the Snap Store

Ubuntu

If you are using Ubuntu linux (17.04 or later), you can install webhook using sudo apt-get install webhook which will install community packaged version.

Debian

If you are using Debian linux ("stretch" or later), you can install webhook using sudo apt-get install webhook which will install community packaged version (thanks @freeekanayaka) from https://packages.debian.org/sid/webhook

FreeBSD

If you are using FreeBSD, you can install webhook using pkg install webhook.

Download prebuilt binaries

Prebuilt binaries for different architectures are available at GitHub Releases.

Configuration

Next step is to define some hooks you want webhook to serve. webhook supports JSON or YAML configuration files, but we'll focus primarily on JSON in the following example. Begin by creating an empty file named hooks.json. This file will contain an array of hooks the webhook will serve. Check Hook definition page to see the detailed description of what properties a hook can contain, and how to use them.

Let's define a simple hook named redeploy-webhook that will run a redeploy script located in /var/scripts/redeploy.sh. Make sure that your bash script has #!/bin/sh shebang on top.

Our hooks.json file will now look like this:

[
  {
    "id": "redeploy-webhook",
    "execute-command": "/var/scripts/redeploy.sh",
    "command-working-directory": "/var/webhook"
  }
]

NOTE: If you prefer YAML, the equivalent hooks.yaml file would be:

- id: redeploy-webhook
  execute-command: "/var/scripts/redeploy.sh"
  command-working-directory: "/var/webhook"

You can now run webhook using

$ /path/to/webhook -hooks hooks.json -verbose

It will start up on default port 9000 and will provide you with one HTTP endpoint

http://yourserver:9000/hooks/redeploy-webhook

Check webhook parameters page to see how to override the ip, port and other settings such as hook hotreload, verbose output, etc, when starting the webhook.

By performing a simple HTTP GET or POST request to that endpoint, your specified redeploy script would be executed. Neat!

However, hook defined like that could pose a security threat to your system, because anyone who knows your endpoint, can send a request and execute your command. To prevent that, you can use the "trigger-rule" property for your hook, to specify the exact circumstances under which the hook would be triggered. For example, you can use them to add a secret that you must supply as a parameter in order to successfully trigger the hook. Please check out the Hook rules page for detailed list of available rules and their usage.

Multipart Form Data

webhook provides limited support the parsing of multipart form data. Multipart form data can contain two types of parts: values and files. All form values are automatically added to the payload scope. Use the parse-parameters-as-json settings to parse a given value as JSON. All files are ignored unless they match one of the following criteria:

  1. The Content-Type header is application/json.
  2. The part is named in the parse-parameters-as-json setting.

In either case, the given file part will be parsed as JSON and added to the payload map.

Templates

webhook can parse the hooks configuration file as a Go template when given the -template CLI parameter. See the Templates page for more details on template usage.

Using HTTPS

webhook by default serves hooks using http. If you want webhook to serve secure content using https, you can use the -secure flag while starting webhook. Files containing a certificate and matching private key for the server must be provided using the -cert /path/to/cert.pem and -key /path/to/key.pem flags. If the certificate is signed by a certificate authority, the cert file should be the concatenation of the server's certificate followed by the CA's certificate.

TLS version and cipher suite selection flags are available from the command line. To list available cipher suites, use the -list-cipher-suites flag. The -tls-min-version flag can be used with -list-cipher-suites.

Running behind a reverse proxy

webhook may be run behind a "reverse proxy" - another web-facing server such as Apache httpd or Nginx that accepts requests from clients and forwards them on to [webhook][h]. You can have webhook listen on a regular TCP port or on a Unix domain socket (with the -socket flag), then configure your proxy to send requests for a specific host name or sub-path over that port or socket to webhook.

Note that when running in this mode the ip-whitelist trigger rule will not work as expected, since it will be checking the address of the proxy, not the client. Client IP restrictions will need to be enforced within the proxy, before it decides whether to forward the request to webhook.

CORS Headers

If you want to set CORS headers, you can use the -header name=value flag while starting webhook to set the appropriate CORS headers that will be returned with each response.

Running under systemd

On platforms that use systemd, webhook supports the socket activation mechanism. If webhook detects that it has been launched from a systemd-managed socket it will automatically use that instead of opening its own listening port. See the systemd page for full details.

Interested in running webhook inside of a Docker container?

You can use one of the following Docker images, or create your own (please read this discussion):

Examples

Check out Hook examples page for more complex examples of hooks.

Guides featuring webhook

Community Contributions

See the webhook-contrib repository for a collections of tools and helpers related to webhook that have been contributed by the webhook community.

Need help?

Check out existing issues to see if someone else also had the same problem, or open a new one.

Support active development

Sponsors

DigitalOcean

DigitalOcean is a simple and robust cloud computing platform, designed for developers.

BrowserStack

BrowserStack is a cloud-based cross-browser testing tool that enables developers to test their websites across various browsers on different operating systems and mobile devices, without requiring users to install virtual machines, devices or emulators.


Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

By contributing

This project exists thanks to all the people who contribute. Contribute!.

By giving money


Thank you to all our backers!

License

The MIT License (MIT)

Copyright (c) 2015 Adnan Hajdarevic adnanh@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

관련 저장소
pppscn/SmsForwarder

短信转发器——监控Android手机短信、来电、APP通知,并根据指定规则转发到其他手机:钉钉群自定义机器人、钉钉企业内机器人、企业微信群机器人、飞书机器人、企业微信应用消息、邮箱、bark、webhook、Telegram机器人、Server酱、PushPlus、手机短信等。包括主动控制服务端与客户端,让你轻松远程发短信、查短信、查通话、查话簿、查电量等。(V3.0 新增)PS.这个APK主要是学习与自用,如有BUG请提ISSUE,同时欢迎大家提PR指正

KotlinBSD 2-Clause "Simplified" Licensesmsdingding
27.2k3.3k
risingwavelabs/risingwave

Event streaming platform for agentic AI. Continuously ingest, transform, and serve event streams in real time, at scale.

Rustcrates.ioApache License 2.0databasestream-processing
go.risingwave.com/slack
9.2k798
Thysrael/Horizon

📡 Your own AI-powered news radar. Generates daily briefings in English & Chinese. | 用 AI 构建你专属的新闻雷达

PythonPyPIMIT Licenseaggregatornews
horizon1123.top
8.3k1.2k
webhooksite/webhook.site

⚓️ Easily test HTTP webhooks with this handy tool that displays requests instantly.

JavaScriptnpmOtherwebhookangular
webhook.site
6.7k525
rubenlagus/TelegramBots

Java library to create bots using Telegram Bots API

JavaMavenMIT Licensetelegram-bottelegram-bots-api
telegram.me/JavaBotsApi
5.5k1.4k
svix/svix-webhooks

The open source and enterprise-ready webhooks service 🦀

Rustcrates.ioMIT Licensewebhooksrust
svix.com
3.3k261
keel-hq/keel

Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates

GoGo ModulesMozilla Public License 2.0kubernetesdocker
keel.sh
2.7k318
bubenshchykov/ngrok

Expose your localhost to the web. Node wrapper for ngrok.

JavaScriptnpmngroktunneling
ngrok.com
2.4k319
zdz/ServerStatus-Rust

✨ Rust 版 ServerStatus 探针、威力加强版

Rustcrates.ioApache License 2.0rustserverstatus
ssr.rs
2.3k386
danni-cool/wechatbot-webhook

轻量、可部署的微信机器人webhook服务,使用http接口收发微信消息, 用它作为个人通知、AIGC 应用或者 coze、n8n等自动化工作流的消息节点

JavaScriptnpmMIT Licensebothttp-service
2.2k353
fabston/TradingView-Webhook-Bot

📊 Send TradingView alerts to Telegram, Discord, Slack, Twitter and Email.

PythonPyPIMIT Licensewebhookbot
1.8k502
standard-webhooks/standard-webhooks

The Standard Webhooks specification

JavaMavenApache License 2.0apiasyncapi
standardwebhooks.com
1.7k63