github-webhook工具实现github自动构建
2010 年 12 月 4 日
原理
当本地 git push origin master
向Github远程仓库提交代码时,可以通过配置github自带webhook向服务器发送请求,利用github-webhook工具在服务器端接到请求后,调用自定义shell脚本来实现自动构建
github-webhook 文档
使用github-webhook
源码: https://github.com/yezihack/github-webhook 别忘记点个小星星哦.
1. 下载github-webhook工具
https://github.com/yezihack/github-webhook/releases
github release下载太慢, 试试这个
wget http://img.sgfoot.com/github-webhook1.4.1.linux-amd64.tar.gz
2. 运行github-webhook
安装
tar -zxvf github-webhook1.4.1.linux-amd64.tar.gz cp github-webhook /usr/bin/ chmod u+x /usr/bin/github-webhook
运行
-b -s
# 非后台运行 github-webhook -b [shell脚本路径] -s [github webhook设置的密码] # 后台运行 nohup github-webhook -b [shell脚本路径] -s [github webhook设置的密码] & # 定向日志输出 `nohup github-webhook -b ~/sh/hugo2www.sh -s qweqwe >> ~/logs/webhook.log 2>&1 &`
配置github webhook
github-webhook -s
测试
git push后, 你就可以看到github推送的信息
git push origin master