Yet another GitHub Webhook listener, built with rifling.
Use cargo
:
bash
cargo install trigger
Download binary from GitHub release, and move it to your PATH
.
Commandline help:
bash
trigger --help
Start the program
bash
trigger "<path to config file>"
Trigger's configurations are in YAML format.
Example:
```yaml
settings: host: 0.0.0.0:4567 # Host address trigger is going to listen secret: "secret" # Secret used to authenticate payload (Optional) printcommands: false # Print command or not (Optional, default: false) captureoutput: false # Capture output of the commands (Optional, default: false) exitonerror: true # Exit on error in commands (Optional, default: false)
events: common: | set -e; PAYLOAD='{payload}'; function getprop { echo $(echo ${PAYLOAD} | jq $1 | tr -d '"'); } SENDER=$(getprop '.sender.login'); SENDERID=$(getprop '.sender.id'); all: echo "This command will be executed in all the events, the current event is {event}"; push: echo "User \"{SENDER}\" with ID \"{SENDERID}\" pushed to this repository"; watch: | ACTION=$(getprop '.action'); echo "GitHub user \"${SENDER}\" with ID \"${SENDERID}\" ${ACTION} watching this repository"; else: echo "\"${SENDER}\" with ID \"${SENDERID}\" sent {event} event"; ```
events.common
will be executed before the actual event.events.all
will be executed in all events.else
will be executed when no matching event defined.{payload}
in commands will be replaced with unparsed payload.
unknown
):
{id}
will be replaced with ID of the event(UUID).{event}
will be replaced with type of the event.{signature}
will be replaced with signature of the payload.{request_body}
will be replaced with body of the request.It is also recommended to use it with a reverse proxy, such as nginx:
nginx
location /hook {
proxy_pass http://0.0.0.0:9999/;
}
Systemd unit (trigger.service
):
```systemd
[Unit]
Description=Yet another GitHub Webhook listener
After=network-online.target
[Service] Type=simple WorkingDirectory=/path/to/your/config/ ExecStart=/path/to/trigger /path/to/your/config/file.yaml Restart=always RestartSec=3
[Install] WantedBy=multi-user.target
```
This software is distributed under the terms of MIT license, for more details, please consult LICENSE file.
Trigger uses prettyenvlogger and log to log.
Trigger uses yaml-rust to parse configurations.
Trigger uses hyper to create web server.
Trigger uses run_script to run shell code.