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.
bash <(curl -sSL https://raw.githubusercontent.com/RustLangES/grhooks/main/scripts/install.sh)
powershell -ExecutionPolicy Bypass -c "$ProgressPreference='SilentlyContinue'; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/RustLangES/grhooks/main/scripts/install.ps1'))"
GRHooks uses a configuration file in TOML, YAML, or JSON format. The file should contain the server settings and webhook definitions.
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"]
Field | Type | Description | Default | Required |
---|---|---|---|---|
port | u16 | Port to listen on | - | Yes |
verbose | String | Logging verbosity level (0-4) | "0" | No |
Each webhook is defined in the webhooks
array with the following options:
Field | Type | Description | Required |
---|---|---|---|
path | String | URL path for the webhook | No (defaults to /) |
secret | Option | Secret for validating webhook signatures | No |
events | Vec | List of events this webhook should handle (use ["*"] for all events) |
Yes |
shell | Option<Vec> | Custom shell and arguments to use for command execution | No (defaults to /bin/sh -c ) |
command | Option | Command to execute when webhook is triggered | Either command or script must be set |
script | Option | Path to script file to execute when webhook is triggered | Either command or script must be set |
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.
${{event.type}}
: The event type that triggered the webhook
grhooks [-v...] /path/to/config.[toml|yaml|json]
Options:
-v
: Increase verbosity (can be used multiple times)
GRHOOKS_MANIFEST_DIR
: Path to configuration fileGRHOOKS_LOG
: Set logging verbosity (0-4 or trace, info, debug, warning, error)
When a secret
is configured in the webhook:
- GRHooks will validate the
X-Hub-Signature-256
header - Only requests with valid signatures will be processed
- The secret should match what's configured in your Git provider
-
Deployment Automation:
[[webhooks]] path = "deploy-prod" events = ["deployment"] command = "kubectl set image deployment/myapp app=${{event.deployment.payload.image}}"
-
CI/CD Pipeline:
[[webhooks]] path = "build" script = "scripts/ci-pipeline.sh" events = ["push"]
-
Notification System:
[[webhooks]] path = "notify" events = ["*"] command = "curl -X POST -d '{\"text\":\"Event ${{event.type}} received\"}' $SLACK_WEBHOOK"
GRHooks currently supports webhooks from:
- GitHub
Plans to support:
- GitLab
- Bitbucket