trigger 0.3.0

Yet another GitHub Webhook listener
Documentation

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:
        • 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

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