From 97224ce6b7992ef3cb14e22087305a24abbf542e Mon Sep 17 00:00:00 2001 From: taloric Date: Wed, 11 Mar 2026 20:08:44 +0800 Subject: [PATCH] feat: add ai-devel --- .github/workflows/ai-devel.yaml | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/ai-devel.yaml diff --git a/.github/workflows/ai-devel.yaml b/.github/workflows/ai-devel.yaml new file mode 100644 index 0000000..e2eab84 --- /dev/null +++ b/.github/workflows/ai-devel.yaml @@ -0,0 +1,77 @@ +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.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') && + ( + (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'))) + ) + 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 Info + id: pr_info + run: | + if PR_DATA=$(gh pr view $ISSUE_NUMBER --repo ${{ github.repository }} --json headRefName,headRepository,author,isCrossRepository 2>/dev/null); then + HEAD_REF_NAME=$(echo "$PR_DATA" | jq -r .headRefName) + IS_FORK=$(echo "$PR_DATA" | jq -r .isCrossRepository) + if [ "$IS_FORK" = "true" ]; then + echo "This is a FORKED PR. Manually constructing repository name." + REPO_NAME=$(echo "$PR_DATA" | jq -r .headRepository.name) + AUTHOR_LOGIN=$(echo "$PR_DATA" | jq -r .author.login) + HEAD_REPOSITORY="$AUTHOR_LOGIN/$REPO_NAME" + else + echo "This is an INTERNAL PR. Using the current repository name." + HEAD_REPOSITORY="${{ github.repository }}" + fi + echo "Final Repository Name: $HEAD_REPOSITORY" + echo "Final Branch Name: $HEAD_REF_NAME" + echo "repo_full_name=$HEAD_REPOSITORY" >> $GITHUB_OUTPUT + echo "branch_name=$HEAD_REF_NAME" >> $GITHUB_OUTPUT + else + echo "Final Repository Name: ${{ github.repository }}" + echo "Final Branch Name: ${{ github.event.repository.default_branch }}" + echo "repo_full_name=${{ github.repository }}" >> $GITHUB_OUTPUT + echo "branch_name=${{ github.event.repository.default_branch }}" >> $GITHUB_OUTPUT + fi + env: + GH_TOKEN: ${{ github.token }} + ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} + - name: Checkout repository + uses: actions/checkout@v6 + with: + repository: ${{ steps.pr_info.outputs.repo_full_name }} + ref: ${{ steps.pr_info.outputs.branch_name }} + fetch-depth: 0 + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + env: + ANTHROPIC_BASE_URL: "${{ secrets.ANTHROPIC_BASE_URL }}" + CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1 + CLAUDE_CODE_ATTRIBUTION_HEADER: 0 + DISABLE_TELEMETRY: 1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + claude_args: | + --model claude-opus-4-6 + --max-turns 100