Claude Code + GitHub Actions自動修改Issue

Claude Code + GitHub Actions的功能

  • 立即產生 PR、補 bug 或實作功能:只要在 issue 或 PR 留言 @claude implement ...,Claude 就會自動完成工作,並提交 PR 。
  • 自動代碼審查:PR 中問一句 @claude review code level,由 AI 幫忙分析與修正錯誤。
  • 符合既有專案標準:Claude 會自動參考專案裡的 CLAUDE.md 內容,比照程式風格與工程規範
  • 簡易設定,立刻上手:可以透過 CLI /install-github-app 快速部署,也可手動安裝 workflow。

    GitHub Actions安裝步驟

    claude
    /install-github-app
    

    接著輸入要連接的repository,這邊我選擇我的開源專案:

    https://github.com/cochiachang/walkassure

    接著在Github設定Claude的API Key

    如何使用

    在專案內增加.github/workflows/claude.yml

    請參考https://github.com/cochiachang/walkassure/tree/main/.github/workflows

    name: Claude AI Workflow
    
    on:
      issues:
        types: [opened, edited, labeled]
      issue_comment:
        types: [created]
    
    jobs:
      claude-analysis:
          runs-on: ubuntu-latest
          if: contains(github.event.issue.body, '@claude') || contains(github.event.comment.body, '@claude')
    
          steps:
            - name: Checkout code
              uses: actions/checkout@v4
    
            - name: Claude AI 回應
              uses: anthropics/claude-code-action@beta
              with:
                anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    
            - name: Claude AI 呼叫成功通知
              if: always()
              run: echo "✅ Claude 回應觸發成功!"
      notify:
        runs-on: ubuntu-latest
        needs: [claude-analysis]
        if: always()
        
        steps:
        - name: Send notification
          run: |
            echo "Workflow completed"
            echo "Claude analysis status: ${{ needs.claude-analysis.result }}"
            echo "Build and test status: ${{ needs.build-and-test.result }}"
    

    範例的issue

    https://github.com/cochiachang/walkassure/issues/1

    接著就可以看到claude已經回應了一個修正