#github #gitlab #ci #webhook

bin+lib trigger

Yet another GitHub/GitLab Webhook listener

10 releases (4 stable)

1.1.2 Jul 17, 2020
1.1.1 Apr 25, 2019
0.4.2 Apr 22, 2019
0.3.0 Mar 17, 2019
0.1.0 Jan 1, 2019

#369 in HTTP server

Download history 12/week @ 2023-11-11 2/week @ 2023-11-18 22/week @ 2023-11-25 10/week @ 2023-12-02 11/week @ 2023-12-16 20/week @ 2023-12-23 10/week @ 2023-12-30 1/week @ 2024-01-06 3/week @ 2024-01-13 26/week @ 2024-01-20 20/week @ 2024-01-27 25/week @ 2024-02-10 139/week @ 2024-02-17

184 downloads per month

MIT license

253 lines


license crates.io Travis-CI

English(Chinglish), 简体中文

Yet another GitHub/GitLab Webhook listener, run shell commands with the events received from GitHub/GitLab.

Built with rifling.


  • Use cargo:

    cargo install trigger
  • Download binary (currently Linux only) from GitHub release, and move it to your PATH.


Commandline help:

trigger --help

Start the program

trigger --config "<path to config file>"

Or, start trigger with debug log enabled:

TRIGGER_LOG=debug trigger --config "<path to config file>"

debug can be replaced with any other logging level you like (including error, warn, info, debug, trace).


Trigger's configurations are in YAML format.


# Sample config

  host:    # Host address trigger is going to listen
  secret: "secret"      # Secret used to authenticate payload (Optional)
  print_commands: false # Print command or not (Optional, default: false)
  capture_output: false # Capture output of the commands (Optional, default: false)
  exit_on_error: true   # Exit on error in commands (Optional, default: false)
  kotomei: true         # Warn you about letting @kotomei study for his exam or not (Optional, default: true)

  common: |
    set -e;
    function get_prop {
      echo $(echo ${PAYLOAD} | jq $1 | tr -d '"');
    SENDER=$(get_prop '.sender.login');
    SENDER_ID=$(get_prop '.sender.id');
  all: echo "This command will be executed in all the events, the current event is {event}";
  push: echo "User \"${SENDER}\" with ID \"${SENDER_ID}\" pushed to this repository";
  watch: |
    ACTION=$(get_prop '.action');
    echo "GitHub user \"${SENDER}\" with ID \"${SENDER_ID}\" ${ACTION} watching this repository";
  else: echo "\"${SENDER}\" with ID \"${SENDER_ID}\" sent {event} event";
  • Secret is not required, but it's strongly recommended.
  • Commands in events.common will be executed before the actual event.
  • Commands in events.all will be executed after receiving any valid request.
  • All available events are listed here (GitHub) and here (GitLab).
    • Note: Events from GitLab need to be reformatted as replacing " "(whitespaces) with "_"(underscore) and make sure it's in lower case.
      • e.g. Push Hook in GitLab's documentation will be push_hook in trigger's configuration.
  • Commands in events.else will be executed when no matching event defined.
  • Placeholder {payload} in commands will be replaced with unparsed payload.
    • Please use single quotation mark to wrap around it.
    • It is possible to use jq to parse it if needed.
  • Other placeholders (if not included in the delivery, they will be replaced with unknown):
    • {id} will be replaced with UUID of the event (GitHub only, GitLab does not provide this).
    • {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:

location /hook {


  1. To use trigger with docker, pull the image first:
    docker pull kaymw/trigger
  2. Prepare your configuration as mentioned above.
  3. Start the container
    docker run --volume $PWD:/work trigger trigger --config trigger.yaml

Note: In this docker image, trigger's default working directory is /work, and the default port is 4567.

Credit: @musnow

Other Snippets

Systemd unit (trigger.service):

Description=Yet another GitHub Webhook listener

ExecStart=/path/to/trigger /path/to/your/config/file.yaml


#  sy
# ste
# md

License and Credits

This software is distributed under the terms of MIT license, for more details, please consult LICENSE file.

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.


~254K SLoC