perf(component): ⚡ 优化虚拟列表加载更多功能 (#129)

* perf(component): ⚡ 优化虚拟列表加载更多功能

* fix(github): 🐛 修复PR copilot 工作流问题

* fix(github): 🐛 修复PR copilot工作流没安装pnpm问题

* fix(action): 🐛 修改pr分析的机器人为通义千问

* fix(action): 🐛 修复配置通义千问配置问题

* fix(action): 🐛 修复api调用方式
This commit is contained in:
Dawn
2024-12-28 17:26:25 +08:00
committed by GitHub
parent 451ded82c5
commit a1641e96cc
4 changed files with 132 additions and 26 deletions
+91
View File
@@ -0,0 +1,91 @@
name: PR Review Bot
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get PR diff
id: diff
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
DIFF=$(git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
echo "DIFF<<EOF" >> $GITHUB_ENV
echo "$DIFF" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9
run_install: false
- name: Install OpenAI SDK
run: |
pnpm config set registry https://registry.npmmirror.com/
pnpm add openai
- name: Analyze PR
id: analyze
uses: actions/github-script@v7
env:
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
with:
script: |
const OpenAI = require('openai');
const openai = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});
const diff = process.env.DIFF;
try {
const completion = await openai.chat.completions.create({
model: "qwen-plus",
messages: [{
role: "system",
content: "你是一个代码审查助手,请用中文分析以下代码变更。"
}, {
role: "user",
content: `请分析以下代码变更并总结主要改动:\n\n${diff}`
}],
temperature: 0.7,
max_tokens: 1000
});
const analysis = completion.choices[0].message.content;
core.setOutput('analysis', analysis);
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## PR 代码分析
${analysis}
---
*这是由通义千问 AI 自动生成的 PR 分析,仅供参考。*`
});
} catch (error) {
core.setFailed(`分析失败: ${error.message}`);
}