Skip to content

Commit ef74c5e

Browse files
author
sunminghui
committed
更新Github相关说明
1 parent be61f2c commit ef74c5e

File tree

6 files changed

+42
-19
lines changed

6 files changed

+42
-19
lines changed

biz/github/webhook_handler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
import os
33
import re
44
import time
5-
from urllib.parse import urljoin
65

76
import requests
8-
from dotenv import load_dotenv
97

108
from biz.utils.log import logger
119

12-
load_dotenv()
1310
# 从环境变量中获取支持的文件扩展名
1411
SUPPORTED_EXTENSIONS = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
1512

biz/gitlab/webhook_handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
from urllib.parse import urljoin
55

66
import requests
7-
from dotenv import load_dotenv
87

98
from biz.utils.log import logger
109

11-
load_dotenv()
1210
# 从环境变量中获取支持的文件扩展名
1311
SUPPORTED_EXTENSIONS = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
1412

biz/queue/worker.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import traceback
33
from datetime import datetime
44

5-
from dotenv import load_dotenv
6-
75
from biz.entity.review_entity import MergeRequestReviewEntity, PushReviewEntity
86
from biz.event.event_manager import event_manager
97
from biz.gitlab.webhook_handler import filter_changes, MergeRequestHandler, PushHandler
@@ -12,7 +10,6 @@
1210
from biz.utils.im import notifier
1311
from biz.utils.log import logger
1412

15-
load_dotenv()
1613
PUSH_REVIEW_ENABLED = os.environ.get('PUSH_REVIEW_ENABLED', '0') == '1'
1714

1815

biz/utils/queue.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import os
22
from multiprocessing import Process
33

4-
from dotenv import load_dotenv
54
from redis import Redis
65
from rq import Queue
76

87
from biz.utils.log import logger
98

10-
load_dotenv()
119
queue_driver = os.getenv('QUEUE_DRIVER', 'async')
1210

1311
if queue_driver == 'rq':

conf/.env.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ REPORT_CRONTAB_EXPRESSION=0 18 * * 1-5
5656
#GITLAB_URL={YOUR_GITLAB_URL} #部分老版本Gitlab webhook不传递URL,需要开启此配置,示例:https://gitlab.example.com
5757
#GITLAB_ACCESS_TOKEN={YOUR_GITLAB_ACCESS_TOKEN} #系统会优先使用此GITLAB_ACCESS_TOKEN,如果未配置,则使用Webhook 传递的Secret Token
5858

59+
#Github配置(如果使用 Github 作为代码托管平台,需要配置此项)
60+
#GITHUB_ACCESS_TOKEN={YOUR_GITHUB_ACCESS_TOKEN}
61+
5962
# 开启Push Review功能(如果不需要push事件触发Code Review,设置为0)
6063
PUSH_REVIEW_ENABLED=1
6164

doc/faq.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
### 常见问题
1+
## 常见问题
22

3-
#### 1.Docker 容器部署时,更新 .env 文件后不生效
3+
### Docker 容器部署时,更新 .env 文件后不生效
44

55
**可能原因**
66

@@ -22,7 +22,7 @@ docker-compose up -d
2222

2323
或参考说明文档启动容器。
2424

25-
#### 2. GitLab 配置 Webhooks 时提示 "Invalid url given"
25+
### GitLab 配置 Webhooks 时提示 "Invalid url given"
2626

2727
**可能原因**
2828

@@ -34,7 +34,7 @@ GitLab 默认禁止 Webhooks 访问本地网络地址。
3434
- 在 Outbound requests 部分,勾选 Allow requests to the local network from webhooks and integrations。
3535
- 保存。
3636

37-
#### 3.如何让不同项目的消息发送到不同的群?
37+
### 如何让不同项目的消息发送到不同的群?
3838

3939
**解决方案**
4040

@@ -53,7 +53,7 @@ DINGTALK_WEBHOOK_URL=https://oapi.dingtalk.com/robot/send?access_token={access_t
5353

5454
飞书和企业微信的配置方式类似。
5555

56-
#### 4.如何让不同的Gitlab服务器的消息发送到不同的群?
56+
### 如何让不同的Gitlab服务器的消息发送到不同的群?
5757

5858
在项目的 .env 文件中,配置不同Gitlab服务器的群机器人的 Webhook 地址。
5959
以 DingTalk 为例,配置如下:
@@ -70,7 +70,7 @@ DINGTALK_WEBHOOK_example_gitlab_com=https://oapi.dingtalk.com/robot/send?access_
7070

7171
**优先级:** 优先根据仓库名称匹配webhook地址,其次根据Gitlab服务器地址匹配webhook地址,如果都没有匹配到,则最后使用默认服务器地址
7272

73-
#### 5.docker 容器部署时,连接Ollama失败
73+
### docker 容器部署时,连接Ollama失败
7474

7575
**可能原因**
7676

@@ -85,7 +85,7 @@ OLLAMA_API_BASE_URL=http://127.0.0.1:11434 # 错误
8585
OLLAMA_API_BASE_URL=http://{宿主机/外网IP地址}:11434 # 正确
8686
```
8787

88-
#### 5.如何使用Redis Queue队列?
88+
### 如何使用Redis Queue队列?
8989

9090
**操作步骤**
9191

@@ -96,6 +96,7 @@ docker compose -f docker-compose.rq.yml up -d
9696
```
9797

9898
2.生产模式下,启动容器:
99+
99100
```
100101
docker compose -f docker-compose.prod.yml up -d
101102
```
@@ -108,7 +109,7 @@ docker compose -f docker-compose.prod.yml up -d
108109
WORKER_QUEUE=gitlab_test_cn
109110
```
110111

111-
#### 如何配置企业微信和飞书消息推送?
112+
### 如何配置企业微信和飞书消息推送?
112113

113114
**1.配置企业微信推送**
114115

@@ -129,4 +130,33 @@ WORKER_QUEUE=gitlab_test_cn
129130
#飞书配置
130131
FEISHU_ENABLED=1
131132
FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxx #替换为你的Webhook URL
132-
```
133+
```
134+
135+
### 是否支持对 GitHub 代码库的 Review?
136+
137+
是的,支持。 需完成以下配置:
138+
139+
**1.配置Github Webhook**
140+
141+
- 进入你的 GitHub 仓库 → Settings → Webhooks → Add webhook。
142+
- Payload URL: http://your-server-ip:5001/review/webhook(替换为你的服务器地址)
143+
- Content type选择application/json
144+
- 在 Which events would you like to trigger this webhook? 中选择 Just the push event(或按需勾选其他事件)
145+
- 点击 Add webhook 完成配置。
146+
147+
**2.生成 GitHub Personal Access Token**
148+
149+
- 进入 GitHub 个人设置 → Developer settings → Personal access tokens → Generate new token。
150+
- 选择 Fine-grained tokens 或 tokens (classic) 都可以
151+
- 点击 Create new token
152+
- Repository access根据需要选择
153+
- Permissions需要选择Commit statuses、Contents、Discussions、Issues、Metadata和Pull requests
154+
- 点击 Generate token 完成配置。
155+
156+
**3.配置.env文件**
157+
158+
- 在.env文件中,配置GITHUB_ACCESS_TOKEN:
159+
```
160+
GITHUB_ACCESS_TOKEN=your-access-token #替换为你的Access Token
161+
```
162+

0 commit comments

Comments
 (0)