trigger.rs
Yet another GitHub Webhook listener, built using afterparty.
Usage
- Install
- Prepare your
trigger.yaml
Example:
In this example, trigger will:listen: host: 0.0.0.0:9999 secret: asdasdasd events: push: bash -c generate.sh watch: echo Yooooooooooooooooooo
- Bind
0.0.0.0:9999
- Execute
bash -c generate
after receiving a valid payload with secretasdasdasd
and eventpush
. - Echo
Yooooooooooooooooooo
after receiving a valid payload with eventwatch
.
- Bind
- Prepare reverse proxy, for example, nginx:
Note: It's always recommended to use a reverse proxy.location /hook { proxy_pass http://0.0.0.0:9999/; }
- Start trigger
- And that's it.
Details
- In
trigger.yaml
:- In
listen
section:secret
isn't necessary, but without it trigger won't be able to check payload's validity.
- In
events
section:- Available events:
- check_run
- check_suite
- commit_comment
- content_reference
- create
- delete
- deployment
- deployment_status
- fork
- gollum
- installation
- installation_repository
- issue_comment
- issues
- label
- marketplace_purchase
- member
- membership
- milestone
- org_block
- organization
- page_build
- project
- project_card
- project_column
- public
- pull_request
- pull_request_review
- pull_request_review_comment
- push
- release
- repository
- repository_import
- repository_vulnerability_alert
- security_advisory
- status
- team
- team_add
- watch
- unknown (which may be a unreachable pattern)
- Commands:
- It's okay to use POSIX shell syntax in the commands here.
{payload}
will be replaced with unparsed payload
- Available events:
- In
Other Snippets
Systemd unit (trigger.service
):
[Unit]
Description=Yet another GitHub Webhook listener
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/path/to/your/config/file
ExecStart=/path/to/trigger
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
Future Plans
-
Migrate afterparty to newer version of hyper if possible.- Switched to afterparty-ng.
- Command line helper.
License and Credits
This software is distributed under the terms of MIT license, for more details, please consult LICENSE file.
Trigger (currently) is just a wrapper of afterparty-ng, which is also MIT licensed.
Trigger uses pretty_env_logger 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.