A simple server to receive webhooks and execute commands
Installing from Go:
$ go get -u github.com/miguelmota/go-webhook-server/cmd/gws
Installing pre-compiled binary:
$ wget https://github.com/miguelmota/go-webhook-server/releases/download/v0.0.9/gws_0.0.9_Linux_x86_64.tar.gz
$ tar -xvzf gws_0.0.9_Linux_x86_64.tar.gz gws
$ chmod +x gws
$ sudo mv gws /usr/local/bin/gws
$ gws --help
Example of setting up a Github webhook:
$ export SECRET_TOKEN=mysecret
$ gws -port=8080 -path=/postreceive -command='echo "hello world"'
Method: GET
Path: /postreceive
Command: echo "hello world"
Listening on port 8080
$ curl "http://localhost:8080/postreceive" -X 'X-Hub-Signature: sha1=33f9d709782f62b8b4a0178586c65ab098a39fe2'
hello world
Example of how to use bash script as the command:
$ cat > command.sh
#!/bin/bash
echo 'hello world'
^C
$ chmod +x command.sh
$ gws -path=/postreceive -command=$(pwd)/command.sh
Example of how to read the payload in bash:
$ cat > command.sh
#!/bin/bash
payload=$(</dev/stdin)
echo $payload | jq '.' | cat
^C
$ gws -method=POST -command=$(pwd)/command.sh