搭建 webhooks 自动部署 Github 代码至自建 Linux 服务器
最近发现了一个 Go 写的 Webhook 库,一个json文件就能完成配置,用起来非常方便,于是就动手给博客服务器加上了自动部署的 webhook。 下载 adnanh/webhook 就是上面说到的库了,Ubuntu 17.04 及之后的版本可以直接通过 apt install webhook, 而较老的版本或其他分支,可以直接在 Release 页面下载对应的预编译版本或者克隆下来从源码编译。 json配置文件 首先创建一个 json 配置文件。 [ { "id": "deploy-repo", "execute-command": "/path/to/deploy.sh", "response-message": "Executing deploy script", "trigger-rule": { "and": [{ "match": { "type": "payload-hash-sha1", "secret": "my-secert", "parameter": { "source": "header", "name": "X-Hub-Signature" } } }, { "match": { "type": "value", "value": "refs/heads/master", "parameter": { "source": "payload", "name": "ref" } } }] } } ] ...