Skip to content

Commit 7eaf7af

Browse files
committed
feat: 更新文档,添加仓库匹配功能和配置说明,优化使用指南
1 parent a94d5c2 commit 7eaf7af

File tree

6 files changed

+91
-40
lines changed

6 files changed

+91
-40
lines changed

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- 支持 Webhook 签名验证,确保请求安全
2727
- 通过 OneBot 协议将推送信息转发到指定的 QQ 群
2828
- 可配置监听的仓库和分支
29+
- 支持大小写不敏感的仓库名匹配
30+
- 支持用户名/* 通配符匹配所有仓库
2931
- 格式化的推送通知消息,包含仓库、分支、推送者和最新提交信息
3032

3133
## 安装
@@ -60,18 +62,34 @@ pip install -r requirements.txt
6062
cp config.yaml.example config.yaml
6163
```
6264

63-
## 配置
64-
65-
`.env` 文件中设置以下环境变量:
66-
67-
| 变量名 | 说明 | 示例 |
68-
|--------|------|------|
69-
| `WS_URL` | OneBot WebSocket 连接地址 | `ws://localhost:8080/ws` |
70-
| `WS_ACCESS_TOKEN` | OneBot 访问令牌 | `your_token` |
71-
| `GITHUB_WEBHOOK_SECRET` | GitHub Webhook 密钥 | `your_secret` |
72-
| `GITHUB_REPO` | 监听的仓库列表 | `["username/repo"]` |
73-
| `GITHUB_BRANCH` | 监听的分支列表 | `["main", "develop"]` |
74-
| `QQ_GROUP` | 通知的 QQ 群号列表 | `[123456789]` |
65+
## 配置说明
66+
67+
配置文件 `config.yaml` 的结构如下:
68+
69+
```yaml
70+
ENV: "production" # 环境变量,可选值为 "production" 或 "development"
71+
WS_URL: "ws://localhost:8080/ws" # OneBot WebSocket 连接地址
72+
WS_ACCESS_TOKEN: "your_token" # OneBot 访问令牌
73+
74+
GITHUB_WEBHOOK:
75+
- NAME: "github" # webhook 名称
76+
REPO: # 监听的仓库列表,支持用户名/* 匹配用户所有仓库
77+
- "username/repo"
78+
- "username/*"
79+
BRANCH: # 监听的分支列表
80+
- "main"
81+
- "develop"
82+
SECRET: "your_secret" # GitHub Webhook 密钥
83+
EVENTS: # 监听的事件类型
84+
- "push"
85+
- "pull_request"
86+
- "issues"
87+
- "issue_comment"
88+
- "release"
89+
ONEBOT: # 通知的 OneBot 目标列表
90+
- type: "group" # 目标类型,可选值为 "group" 或 "private"
91+
id: 123456789 # 目标 ID,群号或用户 ID
92+
```
7593
7694
## 运行
7795
@@ -90,13 +108,14 @@ python app.py
90108
1. 在 GitHub 仓库中前往 Settings -> Webhooks -> Add webhook
91109
2. Payload URL 设置为 `http://你的服务器地址:8000/github-webhook`
92110
3. Content type 选择 `application/json`
93-
4. Secret 填写与 `.env``GITHUB_WEBHOOK_SECRET` 相同的值
111+
4. Secret 填写与配置文件中 `SECRET` 相同的值
94112
5. 选择 "Just the push event" 或根据需要选择事件
95113
6. 启用 webhook(勾选 "Active")
96114

97115
## 项目结构
98116

99117
- [app.py](app.py): 主应用入口和 Web 服务器
118+
- [hooks/github_webhook.py](hooks/github_webhook.py): GitHub Webhook 处理逻辑
100119
- [send_message.py](send_message.py): OneBot 消息发送客户端
101120
- [settings.py](settings.py): 配置加载和验证
102121
- [requirements.txt](requirements.txt): 项目依赖
@@ -107,3 +126,4 @@ python app.py
107126
- Uvicorn: ASGI 服务器
108127
- aiohttp: 异步 HTTP 客户端
109128
- pydantic: 数据验证
129+
- PyYAML: YAML 配置文件解析

docs/src/features.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# 功能特点
1+
## 功能特点
22

33
- 接收 GitHub 的 Webhook 推送事件
44
- 支持 Webhook 签名验证,确保请求安全
55
- 通过 OneBot 协议将推送信息转发到指定的 QQ 群
66
- 可配置监听的仓库和分支
7+
- 支持大小写不敏感的仓库名匹配
8+
- 支持用户名/* 通配符匹配所有仓库
79
- 格式化的推送通知消息,包含仓库、分支、推送者和最新提交信息

docs/src/installation.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# 安装与配置
21

3-
## 安装步骤
2+
## 安装
43

54
1. 克隆本仓库:
65

@@ -34,13 +33,29 @@ cp config.yaml.example config.yaml
3433

3534
## 配置说明
3635

37-
`.env` 文件中设置以下环境变量:
38-
39-
| 变量名 | 说明 | 示例 |
40-
|--------|------|------|
41-
| `WS_URL` | OneBot WebSocket 连接地址 | `ws://localhost:8080/ws` |
42-
| `WS_ACCESS_TOKEN` | OneBot 访问令牌 | `your_token` |
43-
| `GITHUB_WEBHOOK_SECRET` | GitHub Webhook 密钥 | `your_secret` |
44-
| `GITHUB_REPO` | 监听的仓库列表 | `["username/repo"]` |
45-
| `GITHUB_BRANCH` | 监听的分支列表 | `["main", "develop"]` |
46-
| `QQ_GROUP` | 通知的 QQ 群号列表 | `[123456789]` |
36+
配置文件 `config.yaml` 的结构如下:
37+
38+
```yaml
39+
ENV: "production" # 环境变量,可选值为 "production" 或 "development"
40+
WS_URL: "ws://localhost:8080/ws" # OneBot WebSocket 连接地址
41+
WS_ACCESS_TOKEN: "your_token" # OneBot 访问令牌
42+
43+
GITHUB_WEBHOOK:
44+
- NAME: "github" # webhook 名称
45+
REPO: # 监听的仓库列表,支持用户名/* 匹配用户所有仓库
46+
- "username/repo"
47+
- "username/*"
48+
BRANCH: # 监听的分支列表
49+
- "main"
50+
- "develop"
51+
SECRET: "your_secret" # GitHub Webhook 密钥
52+
EVENTS: # 监听的事件类型
53+
- "push"
54+
- "pull_request"
55+
- "issues"
56+
- "issue_comment"
57+
- "release"
58+
ONEBOT: # 通知的 OneBot 目标列表
59+
- type: "group" # 目标类型,可选值为 "group" 或 "private"
60+
id: 123456789 # 目标 ID,群号或用户 ID
61+
```

docs/src/introduction.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
# OneBot GitHub Webhook
1+
<h1 align="center">
2+
OneBot GitHub Webhook
3+
</h1>
24

3-
一个用于接收 GitHub Webhook 并通过 OneBot 协议将推送通知转发到 QQ 群的服务。
5+
<p align="center">
6+
一个用于接收 GitHub Webhook 并通过 OneBot 协议将推送通知转发到 QQ 群的服务。
7+
</p>
48

5-
[![CodeFactor](https://www.codefactor.io/repository/github/AptS-1547/onebot-github-webhook/badge)](https://www.codefactor.io/repository/github/AptS-1547/onebot-github-webhook/)
6-
[![Last Commit](https://img.shields.io/github/last-commit/AptS-1547/onebot-github-webhook/master)](https://github.com/AptS-1547/onebot-github-webhook/activity)
7-
[![License](https://img.shields.io/github/license/AptS-1547/onebot-github-webhook)](./LICENSE)
9+
<p align="center">
10+
<a href="https://www.codefactor.io/repository/github/AptS-1547/onebot-github-webhook/">
11+
<img src="https://www.codefactor.io/repository/github/AptS-1547/onebot-github-webhook/badge" alt="CodeFactor" />
12+
</a>
13+
14+
<a href="https://github.com/AptS-1547/onebot-github-webhook/activity">
15+
<img src="https://img.shields.io/github/last-commit/AptS-1547/onebot-github-webhook/master" alt="Last Commit"/>
16+
</a>
17+
18+
<a href="./LICENSE">
19+
<img src="https://img.shields.io/github/license/AptS-1547/onebot-github-webhook" alt="GPL-3.0\"/>
20+
</a>
21+
</p>

docs/src/structure.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# 项目结构
1+
## 项目结构
22

3-
- [app.py](https://github.com/AptS-1547/onebot-github-webhook/blob/master/app.py): 主应用入口和 Web 服务器
4-
- [send_message.py](https://github.com/AptS-1547/onebot-github-webhook/blob/master/send_message.py): OneBot 消息发送客户端
5-
- [settings.py](https://github.com/AptS-1547/onebot-github-webhook/blob/master/settings.py): 配置加载和验证
6-
- [requirements.txt](https://github.com/AptS-1547/onebot-github-webhook/blob/master/requirements.txt): 项目依赖
3+
- [app.py](app.py): 主应用入口和 Web 服务器
4+
- [hooks/github_webhook.py](hooks/github_webhook.py): GitHub Webhook 处理逻辑
5+
- [send_message.py](send_message.py): OneBot 消息发送客户端
6+
- [settings.py](settings.py): 配置加载和验证
7+
- [requirements.txt](requirements.txt): 项目依赖
78

89
## 依赖
910

1011
- FastAPI: Web 框架
1112
- Uvicorn: ASGI 服务器
1213
- aiohttp: 异步 HTTP 客户端
1314
- pydantic: 数据验证
15+
- PyYAML: YAML 配置文件解析

docs/src/usage.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# 使用指南
2-
3-
## 运行服务
1+
## 运行
42

53
```bash
64
uvicorn app:app --host 0.0.0.0 --port 8000
@@ -17,6 +15,6 @@ python app.py
1715
1. 在 GitHub 仓库中前往 Settings -> Webhooks -> Add webhook
1816
2. Payload URL 设置为 `http://你的服务器地址:8000/github-webhook`
1917
3. Content type 选择 `application/json`
20-
4. Secret 填写与 `.env``GITHUB_WEBHOOK_SECRET` 相同的值
18+
4. Secret 填写与配置文件中 `SECRET` 相同的值
2119
5. 选择 "Just the push event" 或根据需要选择事件
2220
6. 启用 webhook(勾选 "Active")

0 commit comments

Comments
 (0)