Skip to content

Claude code

Claude code #53

Workflow file for this run

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: |
comment=$(cat <<EOF
${{ github.event.comment.body }}
EOF)
{
echo 'EVENT_PROMPT<<EOF'
echo "${{ github.event.label.name == 'claude' && 'Fix this issue and push code; Add a comment to this issue; Remove issue label: claude.' || '' }}"
echo "Issue number: #${{ github.event.issue.number }}"
echo "$comment"
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: |
comment=$(cat <<EOF
${{ github.event.comment.body || github.event.review.body }}
EOF)
{
echo 'EVENT_PROMPT<<EOF'
echo "${{ github.event.action == 'opened' && 'Review this pull request and add a comment to this PR.' || '' }}"
echo "Pull request number: #${{ github.event.pull_request.number }}"
echo "$comment"
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.
If any new git commit is made, MUST push to the remote.
Tasks/workflows should be completed continuously without interruption.
'