update README and server.js for Gitea webhook configuration and endpoint clarity

This commit is contained in:
2025-12-02 14:21:43 +08:00
parent 98340a8244
commit 5d86486f64
2 changed files with 16 additions and 6 deletions

View File

@@ -68,13 +68,20 @@ npm start
## 配置 Gitea Webhook
### 重要:选择正确的 Webhook 类型
确保在 Gitea 中创建 Webhook 时选择 **“Gitea”** 类型而不是“飞书”或其他类型。Gitea 类型会发送结构化的 JSON 数据,便于解析。
### 步骤
1. 进入 Gitea 仓库的设置 → Webhooks → 添加 Webhook
2. 选择 “Gitea” 类型
3. 目标 URL`http://your-server-ip:3000/webhook/gitea`
4. 密钥:填写与 `GITEA_WEBHOOK_SECRET` 相同的值
5. 触发事件:选“工单事件”
2. 选择 **“Gitea”** 类型
3. 目标 URL`http://your-server-ip:3000/webhook/gitea`(也可以使用根路径 `http://your-server-ip:3000/`
4. 密钥:填写与 `GITEA_WEBHOOK_SECRET` 相同的值(可选,但建议设置)
5. 触发事件:选“工单事件”(可根据需要选择其他事件)
6. 保存
### 验证
保存后Gitea 会发送一个测试事件ping。检查服务日志以确认接收成功。
## 飞书机器人配置
1. 在飞书开放平台创建一个自定义机器人,获取 Webhook URL。
@@ -84,7 +91,8 @@ npm start
## API 端点
- `GET /health` 健康检查
- `POST /webhook/gitea` 接收 Gitea Webhook
- `POST /webhook/gitea` 接收 Gitea Webhook(推荐)
- `POST /` 接收 Gitea Webhook备用兼容旧配置
## 日志

View File

@@ -17,8 +17,10 @@ app.get('/health', (req, res) => {
res.status(200).json({ status: 'ok', timestamp: new Date().toISOString() });
});
// Gitea webhook endpoint
// Gitea webhook endpoint (primary)
app.post('/webhook/gitea', giteaWebhookHandler);
// Also accept webhook at root for convenience
app.post('/', giteaWebhookHandler);
// 404 handler
app.use('*', (req, res) => {