Skip to content

Commit 0695c73

Browse files
committed
feat: 添加 GitHub Actions 自动构建 Docker 镜像
- 新增 docker.yml 工作流,支持 push 到 main 和打 tag 时构建 - 更新 README 中 Docker 镜像地址为 ghcr.io/october-coder/api-check - 新增 docs/README.md 项目文档
1 parent 2da9520 commit 0695c73

4 files changed

Lines changed: 279 additions & 2 deletions

File tree

.github/workflows/docker.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository_owner }}/api-check
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=semver,pattern={{version}}
48+
type=semver,pattern={{major}}.{{minor}}
49+
type=sha,prefix=
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@
5757
docker run -d -p 13000:13000 \
5858
-e PASSWORD=you_password \
5959
-v you_path:/app/data \
60-
--name api-check ghcr.io/rickcert/api-check:latest
60+
--name api-check ghcr.io/october-coder/api-check:latest
6161
```
6262

63+
The image is automatically built and pushed via GitHub Actions on every push to the `main` branch. Available tags:
64+
- `latest` - latest main branch build
65+
- `v2.1.0` - specific version tags
66+
- `sha-xxxxxxx` - commit SHA based tags
67+
6368
### Cloudflare Backend Deployment
6469

6570
1. Refer to the [Detailed Tutorial](./docs/cloudflare.md).

README_CN.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@
5555
docker run -d -p 13000:13000 \
5656
-e PASSWORD=you_password \
5757
-v you_path:/app/data \
58-
--name api-check ghcr.io/rickcert/api-check:latest
58+
--name api-check ghcr.io/october-coder/api-check:latest
5959
```
6060

61+
镜像通过 GitHub Actions 自动构建并推送到 `ghcr.io`。可用标签:
62+
- `latest` - 最新 main 分支构建
63+
- `v2.1.0` - 版本标签
64+
- `sha-xxxxxxx` - 提交 SHA 标签
65+
6166
### cloudflare 部署后端
6267

6368
1. 参考 [详细教程](./docs/cloudflare.md)

docs/README.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# API Check 项目文档
2+
3+
## 1. 项目概述
4+
5+
**API Check** 是一个纯前端 OpenAI API 测试工具,用于测试 API 代理的可用性、一致性和真实性。支持 one-api、new-api 及 OpenAI 格式的 API。
6+
7+
- **版本**: 2.1.0
8+
- **技术栈**: Vue 3 + Vite 5 + Ant Design Vue 4 + ECharts 5
9+
- **部署方式**: Vercel / Docker / Cloudflare Pages
10+
11+
---
12+
13+
## 2. 项目结构
14+
15+
```
16+
api-check/
17+
├── api/ # 后端 API (Vercel Serverless / Local Express)
18+
│ ├── index.js # 云存储
19+
│ ├── auth.js # 认证
20+
│ ├── alive.js # 实验性功能
21+
│ └── local/ # 本地 Express 路由
22+
├── src/
23+
│ ├── main.js # Vue 入口
24+
│ ├── App.vue # 根组件
25+
│ ├── components/
26+
│ │ ├── Check.vue # 核心测试组件
27+
│ │ └── Experimental.vue # 实验性功能 (GPT/Claude/Gemini 批量测试)
28+
│ ├── views/
29+
│ │ ├── Home.vue # 首页
30+
│ │ └── Layout.vue # 布局
31+
│ ├── router/index.js # 路由配置
32+
│ ├── utils/
33+
│ │ ├── api.js # API 测试函数
34+
│ │ ├── verify.js # 模型验证器
35+
│ │ ├── normal.js # 辅助函数
36+
│ │ ├── svg.js # SVG 分享卡片
37+
│ │ ├── models.js # 模型列表和预设
38+
│ │ ├── theme.js # 主题切换
39+
│ │ ├── info.js # 应用信息
40+
│ │ └── update.js # 版本检查
41+
│ ├── i18n/ # 国际化
42+
│ └── styles/global.css # 全局样式
43+
├── server.js # Express 生产服务器
44+
└── vite.config.js # Vite 配置
45+
```
46+
47+
---
48+
49+
## 3. 核心功能
50+
51+
### 3.1 API 测试
52+
53+
| 功能 | 说明 |
54+
|------|------|
55+
| 模型可用性测试 | 并发测试多个模型,配置超时和并发数 |
56+
| 模型列表获取 | 从 API 端点获取可用模型列表 |
57+
| 配额检查 | 查询账户使用量和剩余额度 |
58+
| 智能信息提取 | 自动从粘贴文本中提取 URL 和 API Key |
59+
60+
### 3.2 高级验证
61+
62+
| 验证类型 | 说明 |
63+
|----------|------|
64+
| **Temperature 一致性验证** | 使用低温度(0.01)测试模型输出一致性 |
65+
| **官方 API 验证** | 检测系统指纹和响应相似度 |
66+
| **Function Calling 验证** | 测试函数调用能力 |
67+
| **自定义对话验证** | 使用预设 prompt 测试(如"鲁迅暴打周树人")|
68+
69+
### 3.3 存储与分享
70+
71+
- **本地存储**: 保存/加载配置到浏览器 localStorage
72+
- **云存储**: 保存配置到后端(Vercel KV 或本地 Express)
73+
- **SVG 分享卡片**: 生成可分享的结果图片
74+
- **URL 预设**: 通过 URL 参数分享配置
75+
76+
### 3.4 实验性功能
77+
78+
- GPT Refresh Token 批量测试
79+
- Claude Session Key 批量测试
80+
- Gemini API Key 批量测试
81+
82+
---
83+
84+
## 4. 运行逻辑
85+
86+
### 4.1 数据流程
87+
88+
```
89+
用户输入 (API URL + Key + Models)
90+
91+
92+
┌─────────────────────────────┐
93+
│ Check.vue - 主组件 │
94+
│ - 表单验证 │
95+
│ - 模型选择弹窗 │
96+
│ - URL 参数解析 │
97+
└─────────────────────────────┘
98+
99+
100+
┌─────────────────────────────┐
101+
│ api.js - API 测试函数 │
102+
│ - fetchModelList() │
103+
│ - fetchQuotaInfo() │
104+
│ - testModelList() │
105+
└─────────────────────────────┘
106+
107+
108+
┌─────────────────────────────┐
109+
│ 目标 API │
110+
│ - POST /v1/chat/completions │
111+
│ - GET /v1/models │
112+
│ - GET /dashboard/billing/* │
113+
└─────────────────────────────┘
114+
115+
116+
┌─────────────────────────────┐
117+
│ 结果处理 │
118+
│ - ModelVerifier 验证 │
119+
│ - calculateSummaryData() │
120+
└─────────────────────────────┘
121+
122+
123+
┌─────────────────────────────┐
124+
│ UI 展示 │
125+
│ - 可排序列的表格 │
126+
│ - ECharts 雷达图 │
127+
│ - SVG 分享卡片 │
128+
└─────────────────────────────┘
129+
```
130+
131+
### 4.2 关键业务逻辑
132+
133+
#### 模型测试 (`api.js`)
134+
135+
```javascript
136+
testModelList(apiUrl, apiKey, modelNames, timeoutSeconds, concurrency, progressCallback)
137+
```
138+
139+
-`/v1/chat/completions` 发送并发请求
140+
- o1-* 模型超时时间乘以 6
141+
- 结果分类: 有效 / 无效 / 不一致
142+
- 支持进度回调实时更新 UI
143+
144+
#### 模型验证 (`verify.js`)
145+
146+
`ModelVerifier` 类提供 4 种验证方式:
147+
148+
1. **Temperature 验证** - seed=331, temperature=0.01, 发送 4 次请求
149+
2. **官方验证** - 检查 system_fingerprint 和响应相似度
150+
3. **Function Calling** - 测试 add_numbers 函数
151+
4. **自定义对话** - 使用用户提供的 prompt
152+
153+
#### 云存储
154+
155+
| 环境 | 存储方式 |
156+
|------|----------|
157+
| Vercel | `@vercel/kv` (Redis/KV) |
158+
| 本地 | JSON 文件 (`/data/data.json`) |
159+
160+
---
161+
162+
## 5. API 端点
163+
164+
### 本地 Express 服务器
165+
166+
| 路由 | 方法 | 功能 |
167+
|------|------|------|
168+
| `/api/auth` | POST | 密码认证 |
169+
| `/api/alive` | POST | 实验性功能 |
170+
| `/api` | GET | 获取云存储数据 |
171+
| `/api` | POST | 保存云存储数据 |
172+
| `/*` | GET | 静态资源 |
173+
174+
### Vercel Serverless
175+
176+
| 路由 | 文件 | 功能 |
177+
|------|------|------|
178+
| `/api/auth` | `api/auth.js` | 密码认证 |
179+
| `/api/alive` | `api/alive.js` | 实验性功能 |
180+
| `/api` | `api/index.js` | 云存储 (Vercel KV) |
181+
182+
---
183+
184+
## 6. 配置方式
185+
186+
### 环境变量
187+
188+
| 变量 | 说明 |
189+
|------|------|
190+
| `PASSWORD` | 后端认证密码 |
191+
| `PORT` | 服务器端口 (默认: 13000) |
192+
193+
### URL 参数预设
194+
195+
```
196+
?settings={"key":"*sk*","url":"*api*","models":["gpt-4o"],"timeout":10,"concurrency":2}
197+
```
198+
199+
---
200+
201+
## 7. 启动方式
202+
203+
| 环境 | 命令 |
204+
|------|------|
205+
| 开发 | `npm run dev` (Vite, 端口 3000) |
206+
| 构建 | `npm run build` |
207+
| 生产 | `node server.js` (Express, 端口 13000) |
208+
| Docker | `docker run` |

0 commit comments

Comments
 (0)