Claude code #55
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: | |
| issues: | |
| types: [labeled] | |
| issue_comment: | |
| types: [created] | |
| pull_request: | |
| types: [opened] | |
| workflow_dispatch: | |
| inputs: | |
| prompt: | |
| description: Prompt for Claude code | |
| default: '' | |
| show_full_output: | |
| description: Show full output | |
| type: choice | |
| default: '' | |
| options: | |
| - '' | |
| - 'true' | |
| - 'false' | |
| jobs: | |
| claude: | |
| if: | | |
| (github.event_name == 'issues' && github.event.label.name == 'claude') || | |
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request' && github.event.action == 'opened') || | |
| (github.event_name == 'workflow_dispatch') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Setup git identity | |
| run: | | |
| git config --global user.name "claude[bot]" | |
| git config --global user.email "claude[bot]@users.noreply.github.com" | |
| echo "EVENT_KEY=$(date +ci-%y%m%d-${{ github.run_id }})" >> $GITHUB_ENV | |
| - name: Check issue | |
| if: github.event.issue.number | |
| run: | | |
| { | |
| echo 'EVENT_PROMPT<<EOF' | |
| echo '${{ github.event.label.name == 'claude' && 'Fix this issue and push code; Remove issue label `claude`.' || '' }}' | |
| echo 'Issue number: #${{ github.event.issue.number }}' | |
| echo '${{ github.event.comment.body }}' | |
| echo EOF | |
| } >> $GITHUB_ENV | |
| echo "EVENT_KEY=issue-${{ github.event.issue.number }}" >> $GITHUB_ENV | |
| - name: Check pull request | |
| if: github.event.pull_request.number | |
| run: | | |
| { | |
| echo 'EVENT_PROMPT<<EOF' | |
| echo '${{ github.event.action == 'opened' && 'Review this pull request.' || '' }}' | |
| echo 'Pull request number: #${{ github.event.pull_request.number }}' | |
| echo '${{ github.event.comment.body || github.event.review.body }}' | |
| echo EOF | |
| } >> $GITHUB_ENV | |
| echo "EVENT_KEY=pull-${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
| - name: Checkout branch | |
| run: | | |
| BRANCH_NAME="claude/${{ env.EVENT_KEY }}" | |
| git checkout "$BRANCH_NAME" 2>/dev/null || git checkout -b "$BRANCH_NAME" | |
| echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - name: Set up requirements | |
| run: | | |
| uv venv | |
| uv python install | |
| uv pip install -r scripts/requirements.txt | |
| - uses: anthropics/claude-code-action@v1 | |
| id: claude | |
| timeout-minutes: 30 | |
| env: | |
| ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }} | |
| ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.ANTHROPIC_DEFAULT_OPUS_MODEL || vars.CLAUDE_DEFAULT_MODEL }} | |
| ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.ANTHROPIC_DEFAULT_HAIKU_MODEL || vars.CLAUDE_DEFAULT_MODEL }} | |
| ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.ANTHROPIC_DEFAULT_SONNET_MODEL || vars.CLAUDE_DEFAULT_MODEL }} | |
| CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} | |
| with: | |
| prompt: | | |
| ${{ inputs.prompt }} | |
| --- | |
| Repository: ${{ github.repository }} | |
| Branch Name: ${{ env.BRANCH_NAME }} | |
| Context7 Library ID: `/home-assistant/developers.home-assistant` | |
| ${{ env.EVENT_PROMPT }} | |
| show_full_output: ${{ inputs.show_full_output || vars.CLAUDE_FULL_OUTPUT || 'false' }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| claude_code_oauth_token: ${{ secrets.ANTHROPIC_AUTH_TOKEN }} | |
| claude_args: | | |
| --mcp-config .mcp.json | |
| --allowedTools "Read,Edit,MultiEdit,Write,TodoWrite,Glob,Grep,LS,WebFetch,Bash(git:*),Bash(gh:*),Bash(python:*),mcp__tools,mcp__context7" | |
| --append-system-prompt ' | |
| Interact with GitHub using the GitHub CLI commands, such as reading issue and PR details. | |
| After modifying the code, your must be submitted to git and pushed to the remote. | |
| If this task is related to a GitHub issue or PR, you need to add a comment after completing the task. | |
| Tasks/workflows should be completed continuously without interruption. | |
| ' |