Webhook 配置备忘
本文地址:blog.lucien.ink/archives/552
将下列代码保存为 install.sh
,然后 bash install.sh
。
#!/usr/bin/env bash
set -e
wget 'https://github.mirrors.lucien.ink/https://github.com/adnanh/webhook/releases/download/2.8.2/webhook-linux-amd64.tar.gz'
tar -xzvf webhook-linux-amd64.tar.gz
mv webhook-linux-amd64 /usr/local/
cat << EOF > /etc/systemd/system/webhook.service
[Unit]
Description=Webhook server
After=network.target[Service]
Type=simple
ExecStart=/usr/local/webhook-linux-amd64/webhook \-nopanic \-hooks /etc/webhook/hooks.yaml \-hotreload \-logfile /var/log/webhook/webhook.log \-port 9000
Restart=on-failure
User=root
Group=root[Install]
WantedBy=multi-user.target
EOF
systemctl enable webhook
mkdir -p /etc/webhook/scripts
cat << EOF > /etc/webhook/hooks.yaml
- id: testexecute-command: "/etc/webhook/scripts/test.sh"command-working-directory: "/root/"trigger-rule:match:type: valuevalue: Bearer change-thisparameter:source: headername: Authorization
EOF
cat << EOF > /etc/webhook/scripts/test.sh
#!/usr/bin/env sh
echo foo > bar
EOF
chmod +x /etc/webhook/scripts/test.sh
mkdir -p /var/log/webhook
systemctl start webhook
curl 'http://localhost:9000/hooks/test' -H 'Authorization: Bearer change-this'