mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
feat: 添加 auto-issue-fix GitHub Action,ai-fix 标签触发自动修复
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
59
.github/workflows/auto-issue-fix.yml
vendored
Normal file
59
.github/workflows/auto-issue-fix.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Auto Issue Fix
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
auto-fix:
|
||||
# Only trigger when the label is "ai-fix"
|
||||
if: github.event.label.name == 'ai-fix'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
id-token: write
|
||||
actions: read
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
prompt: |
|
||||
You are an expert software engineer. Analyze the following GitHub issue and determine if it can be fixed.
|
||||
|
||||
Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}
|
||||
${{ github.event.issue.body }}
|
||||
|
||||
Instructions:
|
||||
1. Read and understand the issue thoroughly.
|
||||
2. Explore the codebase to find the relevant code.
|
||||
3. If the issue is fixable, implement the fix and create a pull request. Use a clear PR title and description referencing the issue.
|
||||
4. If the issue is NOT fixable (e.g., needs more info, not a bug, out of scope), explain why in a brief summary.
|
||||
5. At the end, output a summary of what you did as your FINAL message. This will be posted as a comment on the issue.
|
||||
claude_args: |
|
||||
--model ${{ vars.CLAUDE_MODEL || 'claude-sonnet-4-20250514' }}
|
||||
--max-turns 30
|
||||
--allowedTools "Edit,Write,Read,Bash,Glob,Grep,Agent"
|
||||
settings: >
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_BASE_URL": "${{ secrets.ANTHROPIC_BASE_URL }}"
|
||||
}
|
||||
}
|
||||
|
||||
- name: Post Claude's response as issue comment
|
||||
if: always() && steps.claude.outputs.result != ''
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh issue comment ${{ github.event.issue.number }} --body "${{ steps.claude.outputs.result }}"
|
||||
Reference in New Issue
Block a user