Webhook 配置备忘

本文地址:blog.lucien.ink/archives/552

将下列代码保存为 install.sh,然后 bash install.sh。

shell 复制代码
#!/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: test
  execute-command: "/etc/webhook/scripts/test.sh"
  command-working-directory: "/root/"
  trigger-rule:
    match:
      type: value
      value: Bearer change-this
      parameter:
        source: header
        name: 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'
相关推荐
水饺编程12 分钟前
第1章,本专栏新增的可自由修改的 Linux 0.12 内核
linux·c语言·汇编
迪康软件zz23 分钟前
审计事件的时间线还原:事件 ID、去重键与索引选择
运维·安全·自动化运维
我命由我1234531 分钟前
Android 广播 - Android 开机广播实现开机自启应用
android·java·linux·java-ee·kotlin·android studio·android-studio
Linux界最忧郁之人34 分钟前
K8s访问控制实战|认证Authentication、鉴权Authorization、准入控制手把手理解与实操
运维·云原生·容器·rpc·kubernetes
凤希AI伴侣40 分钟前
AI 自动化实战:装好只是进门,换习惯才是难关
运维·人工智能·自动化
心如鉄补1 小时前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
沫璃染墨1 小时前
从零入门计算机网络系列(三十一):Linux I/O 多路复用详解——select 工作原理与底层机制
linux·运维·服务器·网络·c++·网络协议·信息与通信
沫璃染墨1 小时前
从零入门计算机网络系列(三十二):Linux I/O 多路复用详解——poll 工作原理、TCP 实战与性能瓶颈
linux·运维·服务器·网络·c++·网络协议·网络安全
是专家不是砖家2 小时前
pthread_mutex_t 踩内存引起的总线错误问题
linux·内存对齐·pthread_mutex_t·1字节对齐
Android系统攻城狮2 小时前
FFmpeg深度解析之av_frame_get_buffer:如何为AVFrame分配缓冲区?(八十四)
linux·ffmpeg·音视频·车载音频·ffmpeg音视频进阶