关于富文本内容识别 #395
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 | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_review_comment: | |
| types: [created] | |
| issues: | |
| types: [opened, assigned] | |
| pull_request_review: | |
| types: [submitted] | |
| jobs: | |
| claude: | |
| if: | | |
| ( | |
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | |
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | |
| ) && ( | |
| github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR' || | |
| github.event.review.author_association == 'OWNER' || | |
| github.event.review.author_association == 'MEMBER' || | |
| github.event.review.author_association == 'COLLABORATOR' || | |
| github.event.issue.author_association == 'OWNER' || | |
| github.event.issue.author_association == 'MEMBER' || | |
| github.event.issue.author_association == 'COLLABORATOR' | |
| ) | |
| 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: Get PR details for checkout | |
| if: github.event.issue.pull_request || github.event_name == 'pull_request_review_comment' || github.event_name == 'pull_request_review' | |
| id: pr_details | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Get PR number from the event | |
| if [ "${{ github.event_name }}" == "issue_comment" ]; then | |
| PR_NUMBER=${{ github.event.issue.number }} | |
| elif [ "${{ github.event_name }}" == "pull_request_review_comment" ]; then | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| elif [ "${{ github.event_name }}" == "pull_request_review" ]; then | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| fi | |
| if [ -n "$PR_NUMBER" ]; then | |
| echo "Fetching PR #$PR_NUMBER details" | |
| PR_DATA=$(gh pr view $PR_NUMBER -R ${{ github.repository }} --json headRefName,headRepository,headRepositoryOwner) | |
| HEAD_REF=$(echo "$PR_DATA" | jq -r '.headRefName') | |
| HEAD_REPO=$(echo "$PR_DATA" | jq -r '.headRepository.name') | |
| HEAD_OWNER=$(echo "$PR_DATA" | jq -r '.headRepositoryOwner.login') | |
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| echo "head_ref=$HEAD_REF" >> $GITHUB_OUTPUT | |
| echo "head_repo=$HEAD_REPO" >> $GITHUB_OUTPUT | |
| echo "head_owner=$HEAD_OWNER" >> $GITHUB_OUTPUT | |
| echo "repository=$HEAD_OWNER/$HEAD_REPO" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ steps.pr_details.outputs.repository || github.repository }} | |
| ref: ${{ steps.pr_details.outputs.head_ref || github.ref }} | |
| fetch-depth: 0 | |
| - name: Run Claude Code | |
| id: claude | |
| uses: anthropics/claude-code-action@v1 | |
| with: | |
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | |
| # This is an optional setting that allows Claude to read CI results on PRs | |
| additional_permissions: | | |
| actions: read | |
| # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. | |
| # prompt: 'Update the pull request description to include a summary of changes.' | |
| # Optional: Add claude_args to customize behavior and configuration | |
| # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | |
| # or https://code.claude.com/docs/en/cli-reference for available options | |
| # claude_args: '--allowed-tools Bash(gh pr:*)' |