# script_change_to_dify **Repository Path**: zouhunter/script_change_to_dify ## Basic Information - **Project Name**: script_change_to_dify - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-29 - **Last Updated**: 2025-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Git Hook Server 基于Go语言的Git Webhook服务器,用于监听Git推送记录并处理文件变更。 ## 功能特性 - 监听Git Webhook推送事件 - 队列处理提交记录 - 文件差异对比(新增、修改、删除) - 集成Dify流程处理服务 - 支持多种Git托管平台(GitHub、GitLab、Gitee等) ## Git Hook URL配置 ### 1. 服务器部署后的Webhook URL格式 ``` http://your-server-domain:10000/webhook ``` 或者使用HTTPS(推荐): ``` https://your-server-domain:10000/webhook ``` ### 2. 不同Git平台的Webhook配置 #### GitHub配置 1. 进入你的GitHub仓库 2. 点击 **Settings** → **Webhooks** → **Add webhook** 3. 填写Payload URL:`https://your-server-domain:10000/webhook` 4. Content type选择:`application/json` 5. Secret填写:你在`config.yaml`中配置的`git.secret` 6. 选择触发事件:**Just the push event** 7. 点击 **Add webhook** #### GitLab配置 1. 进入你的GitLab项目 2. 点击 **Settings** → **Webhooks** 3. 填写URL:`https://your-server-domain:10000/webhook` 4. Secret Token填写:你在`config.yaml`中配置的`git.secret` 5. 勾选 **Push events** 6. 点击 **Add webhook** #### Gitee配置 1. 进入你的Gitee仓库 2. 点击 **管理** → **WebHooks** 3. 填写URL:`https://your-server-domain:10000/webhook` 4. 密码填写:你在`config.yaml`中配置的`git.secret` 5. 勾选 **Push** 6. 点击 **添加** ### 3. 本地开发测试 如果在本地开发,可以使用ngrok等工具创建隧道: ```bash # 安装ngrok npm install -g ngrok # 创建隧道 ngrok http 10000 ``` 然后使用ngrok提供的公网URL: ``` https://abc123.ngrok.io/webhook ``` ### 4. 验证Webhook配置 1. 配置完成后,推送代码到仓库 2. 检查Git平台的Webhook日志 3. 查看服务器日志确认接收到请求 ## 快速开始 1. 克隆项目并安装依赖 2. 修改`config.yaml`配置文件 3. 运行服务器 4. 配置Git平台的Webhook URL 详细配置说明请参考下面的配置文档。 ## 配置说明 ### 服务器配置 (server) - `port`: 服务器监听端口(默认10000) - `host`: 服务器绑定地址(默认0.0.0.0) - `webhook_url`: Webhook接收路径(默认/webhook) ### Git配置 (git) - `secret`: Webhook验证密钥,用于验证请求来源 ### Dify配置 (dify) - `base_url`: Dify API基础URL - `api_key`: Dify API密钥 - `timeout`: 请求超时时间(秒) ## 运行 ```bash # 编译并运行 go run main.go # 或指定配置文件 go run main.go -config custom-config.yaml ```