今天因为发布 gitbook 时想要达到关联仓库对应分支有 commit 则重新编译该 gitbook 功能,接触到 webhooks。
Webhooks 允许你添加对 github 中特定一些事件的监听。当你监听的事件被触发,github 会发送一个 POST 请求给该 webhook 指定的 URL。 Webhook 可以被添加在组织或者仓库上。
- CI
- 部署
- 备份
- ...
就以上面我遇到的编译 gitbook 为例。进入 https://github.com/[username]/[repo name]/settings/hooks
就是当监听的事件被触发时需要 github 向其发送 POST 请求的 URL。我这里是 https://git.gitbook.com/github?book=zaraguo%2Fdaily-learning&username=zaraguo&token=xxxx
请求体:
- 事件相关信息
- sender
- organization / repository
- installation (如果是一个 installation 的 webhook)
请求头包含:
- X-GitHub-Event
- X-Hub-Signature
- X-GitHub-Delivery
- User-Agent(以 GitHub-Hookshot/ 为前缀)
就是选择你监听的事件,可多选。图中对事件都已有简略介绍。
1499 days left