fix(llm): retry transient network errors once before failing polish #266
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 Code | |
| # 触发策略: | |
| # - 默认不主动 review;任何 PR 打开 / 同步都不会自动调用模型,避免烧 OAuth token 额度。 | |
| # - 评论 / review / issue 中出现 `@claude` 才触发,且发起者必须是仓库 OWNER(appergb)。 | |
| # - 模型默认 claude-sonnet-4-6(量大、成本低);评论里写 `--opus` 或包含 `claude-opus` | |
| # 字样会切到 claude-opus-4-7(用于需要更深推理的任务)。 | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_review_comment: | |
| types: [created] | |
| issues: | |
| types: [opened, assigned] | |
| pull_request_review: | |
| types: [submitted] | |
| jobs: | |
| claude: | |
| # 双重门禁:(1) 内容含 @claude (2) 触发者是 OWNER。 | |
| # author_association == 'OWNER' 是 GitHub 内建字段,免一次 API 调用。 | |
| if: | | |
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && github.event.comment.author_association == 'OWNER') || | |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && github.event.comment.author_association == 'OWNER') || | |
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && github.event.review.author_association == 'OWNER') || | |
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) && github.event.issue.author_association == 'OWNER') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| issues: read | |
| id-token: write | |
| actions: read # Required for Claude to read CI results on PRs | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Pick model (default sonnet, opt-in opus) | |
| id: pick_model | |
| env: | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| REVIEW_BODY: ${{ github.event.review.body }} | |
| ISSUE_BODY: ${{ github.event.issue.body }} | |
| ISSUE_TITLE: ${{ github.event.issue.title }} | |
| run: | | |
| set -eu | |
| body="${COMMENT_BODY}${REVIEW_BODY}${ISSUE_BODY}${ISSUE_TITLE}" | |
| if [[ "$body" == *"--opus"* ]] || [[ "$body" == *"claude-opus"* ]]; then | |
| echo "model=claude-opus-4-7" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "model=claude-sonnet-4-6" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run Claude Code | |
| id: claude | |
| uses: anthropics/claude-code-action@v1 | |
| with: | |
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | |
| # 让 Claude 能看 CI 结果 | |
| additional_permissions: | | |
| actions: read | |
| # 模型策略:默认 sonnet,评论里 --opus 才升级到 opus | |
| claude_args: '--model ${{ steps.pick_model.outputs.model }}' |