Skip to content

Repository files navigation

GRHooks - Webhook Server Configuration

GRHooks is a configurable webhook server that can execute commands or scripts in response to incoming webhook events. It supports multiple webhook configurations with flexible command execution options.

Install prebuilt binaries via shell script

bash <(curl -sSL https://raw.githubusercontent.com/RustLangES/grhooks/main/scripts/install.sh)

Install prebuilt binaries via powershell script

powershell -ExecutionPolicy Bypass -c "$ProgressPreference='SilentlyContinue'; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/RustLangES/grhooks/main/scripts/install.ps1'))"

Configuration File

GRHooks uses a configuration file in TOML, YAML, or JSON format. The file should contain the server settings and webhook definitions.

Example Configuration (TOML)

port = 8080
[[webhooks]]
path = "deploy"secret = "mysecret123"# or "${{ env(\"MY_SECRET_FROM_ENV\") }}"events = ["push", "pull_request"]
command = "echo 'Deployment triggered by ${{event.action}}'"
[[webhooks]]
path = "build"shell = ["/bin/bash", "-c"]
script = "scripts/build.sh"events = ["create"]

Configuration Options

Server Configuration

FieldTypeDescriptionDefaultRequired
portu16Port to listen on-Yes
verboseStringLogging verbosity level (0-4)"0"No

Webhook Configuration

Each webhook is defined in the webhooks array with the following options:

FieldTypeDescriptionRequired
pathStringURL path for the webhookNo (defaults to /)
secretOptionSecret for validating webhook signaturesNo
eventsVecList of events this webhook should handle (use ["*"] for all events)Yes
shellOption<Vec>Custom shell and arguments to use for command executionNo (defaults to /bin/sh -c)
commandOptionCommand to execute when webhook is triggeredEither command or script must be set
scriptOptionPath to script file to execute when webhook is triggeredEither command or script must be set

Template Variables

Commands and scripts can use template variables that will be replaced with values from the webhook payload. Variables use the syntax ${{path.to.value}}.

Note

The template is redered using the srtemplate template engine.

Important

If you want to know more about the variables you can use, you should check this link, the hierarchy, names and types are 100% respected in terms of usage, always under the event.* name.

Common Variables

  • ${{event.type}}: The event type that triggered the webhook

Running GRHooks

Command Line Usage

grhooks [-v...] /path/to/config.[toml|yaml|json]

Options:

  • -v: Increase verbosity (can be used multiple times)

Environment Variables

  • GRHOOKS_MANIFEST_DIR: Path to configuration file
  • GRHOOKS_LOG: Set logging verbosity (0-4 or trace, info, debug, warning, error)

Webhook Security

When a secret is configured in the webhook:

  1. GRHooks will validate the X-Hub-Signature-256 header
  2. Only requests with valid signatures will be processed
  3. The secret should match what's configured in your Git provider

Example Use Cases

  1. Deployment Automation:

    [[webhooks]]
    path = "deploy-prod"events = ["deployment"]
    command = "kubectl set image deployment/myapp app=${{event.deployment.payload.image}}"
  2. CI/CD Pipeline:

    [[webhooks]]
    path = "build"script = "scripts/ci-pipeline.sh"events = ["push"]
  3. Notification System:

    [[webhooks]]
    path = "notify"events = ["*"]
    command = "curl -X POST -d '{\"text\":\"Event ${{event.type}} received\"}' $SLACK_WEBHOOK"

Supported Webhook Providers

GRHooks currently supports webhooks from:

Plans to support:

  • Bitbucket

About

Service to listen and manage github webhooks easy

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages