Yet another GitHub webhook listener
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
Cargo.lock
Cargo.toml
LICENSE
README.md
trigger.yaml

README.md

trigger.rs

license crates.io

Yet another GitHub Webhook listener, built using afterparty.

Usage

  • Install
    cargo install trigger
  • Prepare your trigger.yaml
    Example:
    listen:
      host: 0.0.0.0:9999
      secret: asdasdasd
    
    events:
      push: bash -c generate.sh
      watch: echo Yooooooooooooooooooo
    In this example, trigger will:
    • Bind 0.0.0.0:9999
    • Execute bash -c generate after receiving a valid payload with secret asdasdasd and event push.
    • Echo Yooooooooooooooooooo after receiving a valid payload with event watch.
  • Prepare reverse proxy, for example, nginx:
    location /hook {
        proxy_pass http://0.0.0.0:9999/;
    }
    
    Note: It's always recommended to use a reverse proxy.
  • Start trigger
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:
        • commit_comment
        • create
        • delete
        • deployment
        • deployment_status
        • fork
        • gollum
        • issue_comment
        • issues
        • member
        • membership
        • page_build
        • ping
        • public
        • pull_request
        • pull_request_review_comment
        • push
        • release
        • repository
        • status
        • 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

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.
  • 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, 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.