diff --git a/.github/workflows/claude-org-wide.yml b/.github/workflows/claude-org-wide.yml index 3722e70..573f526 100644 --- a/.github/workflows/claude-org-wide.yml +++ b/.github/workflows/claude-org-wide.yml @@ -82,19 +82,62 @@ jobs: ref: ${{ steps.default-branch.outputs.branch }} token: ${{ secrets.PHPSTAN_BOT_TOKEN }} - - name: "Run Claude Code on repository" - uses: anthropics/claude-code-action@v1 + - name: "Setup Node.js" + uses: actions/setup-node@v4 with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - github_token: ${{ secrets.PHPSTAN_BOT_TOKEN }} - trigger_phrase: "@phpstan-bot" - base_branch: ${{ steps.default-branch.outputs.branch }} - claude_args: >- - --model claude-opus-4-6 - --custom-instructions "You are working on the repository ${{ matrix.repo }}. - After making changes, you must create a pull request (not a draft) with your changes. - Do not just push a branch — always open a real, non-draft pull request so the changes can be reviewed and merged." - bot_name: "phpstan-bot" - bot_id: "79867460" - additional_permissions: | - actions: read + node-version: '20' + + - name: "Install Claude CLI" + run: npm install -g @anthropic-ai/claude-code + + - name: "Configure git" + run: | + git config user.name "phpstan-bot" + git config user.email "phpstan-bot " + + - name: "Run Claude Code on repository" + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + GH_TOKEN: ${{ secrets.PHPSTAN_BOT_TOKEN }} + COMMENT_BODY: ${{ github.event.comment.body }} + REPO_NAME: ${{ matrix.repo }} + TRIGGER_PHRASE: "@phpstan-bot" + run: | + # Strip the trigger phrase from the comment to get the actual request + REQUEST=$(echo "$COMMENT_BODY" | sed "s|${TRIGGER_PHRASE}||g" | sed 's/^[[:space:]]*//') + + PROMPT="You are an AI assistant working on the repository ${REPO_NAME}. + + You are being triggered by an issue comment in the phpstan/.github repository. The comment contains a request that should be applied to this repository. + + Here is the request: + ${REQUEST} + + Follow these steps: + + 1. First, check if there is a CLAUDE.md file in the repository root. If it exists, read and follow its instructions and guidelines. + + 2. Understand the request carefully. Read any relevant code before making changes. Do not modify code you have not read. + + 3. Implement the requested changes: + - Keep changes focused and minimal — only make what was requested. + - Do not add unnecessary features, refactoring, or documentation beyond what was asked. + - Be careful not to introduce security vulnerabilities. + - Do not over-engineer the solution. + + 4. After making changes, commit and create a pull request: + - Stage your changes with git add. + - Write a clear, descriptive commit message that explains why the change was made. + - Push your branch and create a non-draft pull request using gh pr create. + - The PR title should be concise and descriptive. + - The PR body should clearly describe what was changed and why. + - Do not just push a branch — always open a real, non-draft pull request so the changes can be reviewed and merged. + + Important: + - Never force push or use destructive git commands. + - Never commit files that may contain secrets (.env, credentials, etc.). + - Only make changes that are directly requested or clearly necessary." + + claude -p "$PROMPT" \ + --model claude-opus-4-6 \ + --dangerously-skip-permissions diff --git a/.github/workflows/claude-react-on-comment.yml b/.github/workflows/claude-react-on-comment.yml index 67d25d3..88a6ff1 100644 --- a/.github/workflows/claude-react-on-comment.yml +++ b/.github/workflows/claude-react-on-comment.yml @@ -31,7 +31,7 @@ jobs: - name: "Check for trigger phrase" id: check env: - COMMENT_BODY: ${{ github.event.comment.body || github.event.review.body || '' }} + COMMENT_BODY: ${{ github.event.comment.body || github.event.review.body || github.event.issue.body || '' }} run: | if echo "$COMMENT_BODY" | grep -qF "@phpstan-bot"; then echo "triggered=true" >> "$GITHUB_OUTPUT"