Enhance serverlist #174
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Claude Auto Review with Tracking | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, ready_for_review, reopened] | |
| pull_request_target: | |
| types: [opened, synchronize, ready_for_review, reopened] | |
| jobs: | |
| # ───────────────────────────────────────── | |
| # 内部 PR 自动审查 | |
| # ───────────────────────────────────────── | |
| review-internal: | |
| if: | | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| github.event.pull_request.user.login != 'claude' && | |
| github.event.pull_request.user.login != 'MCJPG-Agent' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| id-token: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "MCJPG-Agent" | |
| git config --global user.email "agent@mcjpg.org" | |
| # ── 等待前置工作流(若已触发)────────────────────────────────────────── | |
| - name: Wait for "Sync I18n Docs Updates" (if triggered) | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| TARGET_WORKFLOW: "Sync I18n Docs Updates" | |
| # 最长等待时间(秒),超时后仍继续审查,避免永久阻塞 | |
| MAX_WAIT_SECONDS: "600" | |
| # 首次检查前的等待时间,让前置工作流有机会完成初始化 | |
| INITIAL_SLEEP: "20" | |
| run: | | |
| echo "⏳ 初始等待 ${INITIAL_SLEEP}s,让工作流有机会触发..." | |
| sleep "${INITIAL_SLEEP}" | |
| check_runs() { | |
| gh api \ | |
| "repos/${REPO}/actions/runs?head_sha=${HEAD_SHA}&per_page=100" \ | |
| --jq "[.workflow_runs[] | select(.name == \"${TARGET_WORKFLOW}\")]" | |
| } | |
| RUNS=$(check_runs) | |
| COUNT=$(echo "$RUNS" | jq 'length') | |
| if [ "$COUNT" -eq 0 ]; then | |
| echo "✅ 未检测到「${TARGET_WORKFLOW}」工作流,直接执行审查。" | |
| exit 0 | |
| fi | |
| echo "🔍 检测到「${TARGET_WORKFLOW}」工作流(共 ${COUNT} 个实例),开始等待..." | |
| ELAPSED=${INITIAL_SLEEP} | |
| POLL_INTERVAL=20 | |
| while [ "$ELAPSED" -lt "$MAX_WAIT_SECONDS" ]; do | |
| RUNS=$(check_runs) | |
| # 只要还有未完成的实例就继续等待 | |
| PENDING=$(echo "$RUNS" | jq '[.[] | select(.status != "completed")] | length') | |
| if [ "$PENDING" -eq 0 ]; then | |
| CONCLUSIONS=$(echo "$RUNS" | jq -r '[.[] | .conclusion] | unique | join(", ")') | |
| echo "✅「${TARGET_WORKFLOW}」全部完成,结论:${CONCLUSIONS}" | |
| break | |
| fi | |
| echo "⏳ 仍有 ${PENDING} 个实例未完成,已等待 ${ELAPSED}s / ${MAX_WAIT_SECONDS}s ..." | |
| sleep "${POLL_INTERVAL}" | |
| ELAPSED=$((ELAPSED + POLL_INTERVAL)) | |
| done | |
| if [ "$ELAPSED" -ge "$MAX_WAIT_SECONDS" ]; then | |
| echo "⚠️ 等待超时(${MAX_WAIT_SECONDS}s),继续执行审查以避免阻塞。" | |
| fi | |
| # ─────────────────────────────────────────────────────────────────────── | |
| - uses: anthropics/claude-code-action@v1 | |
| with: | |
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | |
| track_progress: true | |
| github_token: ${{ secrets.GH_TOKEN }} | |
| prompt: | | |
| REPO: ${{ github.repository }} | |
| PR NUMBER: ${{ github.event.pull_request.number }} | |
| Please review this pull request with a focus on: | |
| - Code quality and best practices | |
| - Potential bugs or issues | |
| - Security implications | |
| - Performance considerations | |
| Provide detailed feedback using inline comments for specific issues. | |
| 务必使用中文输出审查结果 | |
| claude_args: | | |
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" | |
| --model claude-sonnet-4-6 | |
| settings: | | |
| { | |
| "env": { | |
| "ANTHROPIC_BASE_URL": "https://api.huggingai.org" | |
| } | |
| } | |
| # ───────────────────────────────────────── | |
| # 外部 PR 需要手动审批 | |
| # ───────────────────────────────────────── | |
| review-external: | |
| if: | | |
| github.event_name == 'pull_request_target' && | |
| github.event.pull_request.head.repo.full_name != github.repository && | |
| github.event.pull_request.user.login != 'claude' && | |
| github.event.pull_request.user.login != 'MCJPG-Agent' | |
| runs-on: ubuntu-latest | |
| environment: external-pr-review | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| id-token: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "MCJPG-Agent" | |
| git config --global user.email "agent@mcjpg.org" | |
| # ── 等待前置工作流(若已触发)────────────────────────────────────────── | |
| - name: Wait for "Sync I18n Docs Updates" (if triggered) | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| TARGET_WORKFLOW: "Sync I18n Docs Updates" | |
| MAX_WAIT_SECONDS: "600" | |
| INITIAL_SLEEP: "20" | |
| run: | | |
| echo "⏳ 初始等待 ${INITIAL_SLEEP}s,让工作流有机会触发..." | |
| sleep "${INITIAL_SLEEP}" | |
| check_runs() { | |
| gh api \ | |
| "repos/${REPO}/actions/runs?head_sha=${HEAD_SHA}&per_page=100" \ | |
| --jq "[.workflow_runs[] | select(.name == \"${TARGET_WORKFLOW}\")]" | |
| } | |
| RUNS=$(check_runs) | |
| COUNT=$(echo "$RUNS" | jq 'length') | |
| if [ "$COUNT" -eq 0 ]; then | |
| echo "✅ 未检测到「${TARGET_WORKFLOW}」工作流,直接执行审查。" | |
| exit 0 | |
| fi | |
| echo "🔍 检测到「${TARGET_WORKFLOW}」工作流(共 ${COUNT} 个实例),开始等待..." | |
| ELAPSED=${INITIAL_SLEEP} | |
| POLL_INTERVAL=20 | |
| while [ "$ELAPSED" -lt "$MAX_WAIT_SECONDS" ]; do | |
| RUNS=$(check_runs) | |
| PENDING=$(echo "$RUNS" | jq '[.[] | select(.status != "completed")] | length') | |
| if [ "$PENDING" -eq 0 ]; then | |
| CONCLUSIONS=$(echo "$RUNS" | jq -r '[.[] | .conclusion] | unique | join(", ")') | |
| echo "✅「${TARGET_WORKFLOW}」全部完成,结论:${CONCLUSIONS}" | |
| break | |
| fi | |
| echo "⏳ 仍有 ${PENDING} 个实例未完成,已等待 ${ELAPSED}s / ${MAX_WAIT_SECONDS}s ..." | |
| sleep "${POLL_INTERVAL}" | |
| ELAPSED=$((ELAPSED + POLL_INTERVAL)) | |
| done | |
| if [ "$ELAPSED" -ge "$MAX_WAIT_SECONDS" ]; then | |
| echo "⚠️ 等待超时(${MAX_WAIT_SECONDS}s),继续执行审查以避免阻塞。" | |
| fi | |
| # ─────────────────────────────────────────────────────────────────────── | |
| - uses: anthropics/claude-code-action@v1 | |
| with: | |
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | |
| track_progress: true | |
| github_token: ${{ secrets.GH_TOKEN }} | |
| prompt: | | |
| REPO: ${{ github.repository }} | |
| PR NUMBER: ${{ github.event.pull_request.number }} | |
| PR AUTHOR: ${{ github.event.pull_request.user.login }} (External Contributor) | |
| ⚠️ This is an EXTERNAL pull request. Please review with extra security attention. | |
| Please review this pull request with a focus on: | |
| - Code quality and best practices | |
| - Potential bugs or issues | |
| - **Security implications (CRITICAL for external PRs)** | |
| - Performance considerations | |
| - Malicious code patterns | |
| Provide detailed feedback using inline comments for specific issues. | |
| 务必使用中文输出审查结果 | |
| claude_args: | | |
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" | |
| --model claude-sonnet-4-6 | |
| settings: | | |
| { | |
| "env": { | |
| "ANTHROPIC_BASE_URL": "https://api.huggingai.org" | |
| } | |
| } |