shenjingnan--xiaozhi-client
133 行
4.8 KiB
YAML
133 行
4.8 KiB
YAML
name: Issue Hunter
|
|
|
|
on:
|
|
workflow_dispatch: # 手动触发
|
|
schedule:
|
|
- cron: '*/10 * * * *' # 每10分钟执行一次
|
|
issue_comment:
|
|
types: [created]
|
|
pull_request_review_comment:
|
|
types: [created]
|
|
issues:
|
|
types: [opened, assigned]
|
|
pull_request_review:
|
|
types: [submitted]
|
|
|
|
jobs:
|
|
issue-hunter:
|
|
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
issues: write
|
|
id-token: write
|
|
actions: read # Required for Claude to read CI results on PRs
|
|
steps:
|
|
- name: 检查执行时间
|
|
id: check_time
|
|
if: github.event_name == 'schedule'
|
|
run: |
|
|
# 获取当前 UTC 时间的小时数 (0-23)
|
|
HOUR=$(date -u +"%H")
|
|
# 北京时间 00:00-06:00 对应 UTC 16:00-22:00
|
|
# 检查是否在允许的时间范围内
|
|
if [ "$HOUR" -ge 16 ] && [ "$HOUR" -lt 22 ]; then
|
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
echo "当前时间 UTC ${HOUR}:xx (北京时间 $(( ($HOUR + 8) % 24 )):xx),允许执行"
|
|
else
|
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
|
echo "当前时间 UTC ${HOUR}:xx (北京时间 $(( ($HOUR + 8) % 24 )):xx),不在执行时间范围内"
|
|
fi
|
|
|
|
- name: 检出代码
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: 启用 Corepack
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
run: corepack enable
|
|
|
|
- name: 安装 pnpm
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10.30.3
|
|
|
|
- name: 设置 Node.js
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: ".nvmrc"
|
|
cache: 'pnpm'
|
|
|
|
- name: 安装依赖
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
uses: nick-invision/retry@v3
|
|
with:
|
|
timeout_minutes: 5
|
|
max_attempts: 2
|
|
retry_on: error
|
|
command: pnpm install
|
|
|
|
- name: Create MCP Config
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
env:
|
|
ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }}
|
|
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
|
|
run: |
|
|
cat > /tmp/mcp-config.json << EOF
|
|
{
|
|
"mcpServers": {
|
|
"zai-mcp-server": {
|
|
"type": "stdio",
|
|
"command": "npx",
|
|
"args": ["-y", "@z_ai/mcp-server"],
|
|
"env": {
|
|
"Z_AI_MODE": "ZHIPU",
|
|
"Z_AI_API_KEY": "$ZHIPU_API_KEY"
|
|
}
|
|
},
|
|
"web-search-prime": {
|
|
"type": "http",
|
|
"url": "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp",
|
|
"headers": {
|
|
"Authorization": "Bearer $ZHIPU_API_KEY"
|
|
}
|
|
},
|
|
"web-reader": {
|
|
"type": "http",
|
|
"url": "https://open.bigmodel.cn/api/mcp/web_reader/mcp",
|
|
"headers": {
|
|
"Authorization": "Bearer $ZHIPU_API_KEY"
|
|
}
|
|
},
|
|
"zread": {
|
|
"type": "http",
|
|
"url": "https://open.bigmodel.cn/api/mcp/zread/mcp",
|
|
"headers": {
|
|
"Authorization": "Bearer $ZHIPU_API_KEY"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
- name: Run Claude Code
|
|
id: claude
|
|
if: github.event_name != 'schedule' || steps.check_time.outputs.should_run == 'true'
|
|
uses: anthropics/claude-code-action@v1
|
|
env:
|
|
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL || vars.ANTHROPIC_BASE_URL }}
|
|
ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ inputs.model || vars.ANTHROPIC_DEFAULT_OPUS_MODEL || vars.CLAUDE_DEFAULT_MODEL }}
|
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ inputs.model || vars.ANTHROPIC_DEFAULT_HAIKU_MODEL || vars.CLAUDE_DEFAULT_MODEL }}
|
|
ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ inputs.model || vars.ANTHROPIC_DEFAULT_SONNET_MODEL || vars.CLAUDE_DEFAULT_MODEL }}
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
prompt: "/issue-hunter"
|
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
show_full_output: ${{ vars.CLAUDE_FULL_OUTPUT || 'false' }}
|
|
claude_args: "--dangerously-skip-permissions --mcp-config /tmp/mcp-config.json"
|