1 Star 0 Fork 1

DistributedDB / git-webhooks-server

forked from Holyhi / git-webhooks-server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简易 Git WebHooks 服务

README | 中文说明

目录

简介

  • 使用 Python 3 实现的.
  • 支持 Github、Gitee、Gitlab 及自定义仓库.
  • 支持为不同的仓库指定工作目录和命令.
  • 支持安装为 Systemd 服务.

安装

  • 克隆到任意目录.
  • 执行 ./install.sh 进行安装.
git clone https://github.com/troytse/git-webhooks-server.git
cd git-webhooks-server
./install.sh

install

卸载

cd git-webhooks-server
./install.sh --uninstal

uninstall

使用

  • 在配置文件中添加仓库信息:
# 匹配你的仓库全名
[your_name/repository]
# 工作目录
cwd=/path/to/your/repository
# 收到推送后执行的命令
cmd=git fetch --all & git reset --hard origin/master & git pull
  • 重新启动服务
systemctl restart git-webhooks-server
  • 在你的仓库设置中添加 webhook:

Github:

github github-success

Gitee:

gitee gitee-success

Gitlab:

gitlab gitlab-success

自定义:

  • 对于自定义 webhooks 来源, 你需要像下面这样调整你的配置文件:
[custom]
# 用于识别来源
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
# 用于匹配 secret 的 header
header_token=X-Custom-Token
# 仓库名称在JSON请求数据中的位置
identifier_path=project.path_with_namespace
# 仅支持文本Token的认证
verify=True
secret=123456
  • 处理器接受 application/jsonapplication/x-www-form-urlencoded 格式的请求 (你可以参考 Github / Gitee / Gitlab 中关于请求的指引), 数据格式像这样:
{
  "project": {
    "path_with_namespace": "your_name/repository"
  }
}

custom-header custom-body custom-response

配置

  • 默认配置文件位置: /usr/local/etc/git-webhooks-server.ini.
  • 你可以在安装后修改它.
  • 一个典型的配置文件如下:
[server]
address=0.0.0.0
port=6789
log_file=/var/log/git-webhooks-server.log

[ssl]
enable=False
key_file=/path/to/key.pem
cert_file=/path/to/cert.pem

[github]
verify=True
secret=123456

[gitee]
verify=True
secret=123456

[gitlab]
verify=True
secret=123456

[custom]
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
header_token=X-Custom-Token
identifier_path=project.path_with_namespace
verify=True
secret=123456

[your_name/repository]
cwd=/path/to/your/repository
cmd=git fetch --all & git reset --hard origin/master & git pull

[your_name/sample]
cwd=/path/to/sample
cmd=git fetch --all & git reset --hard origin/master & git pull
MIT License Copyright (c) 2020 Troy Tse <troy@holyhi.net> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

使用 Python 3 实现的简易 git webhooks 服务. 支持 Github、Gitee、Gitlab 及自定义仓库. 支持为不同的仓库指定工作目录和命令. 支持安装为 Systemd 服务. 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/distributed-db/git-webhooks-server.git
git@gitee.com:distributed-db/git-webhooks-server.git
distributed-db
git-webhooks-server
git-webhooks-server
master

搜索帮助