From cadd79e961d4d6bbe3afa7e385cb2e6f909ed635 Mon Sep 17 00:00:00 2001 From: Brett Gregson Date: Tue, 4 Nov 2025 11:26:34 +0100 Subject: [PATCH 1/4] Create bot-change.yml --- .github/workflows/bot-change.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/bot-change.yml diff --git a/.github/workflows/bot-change.yml b/.github/workflows/bot-change.yml new file mode 100644 index 00000000000..b4d00d2b32d --- /dev/null +++ b/.github/workflows/bot-change.yml @@ -0,0 +1,39 @@ +name: Bot change from input +on: + workflow_dispatch: + inputs: + change: + description: 'Short instruction for the bot' + required: true + +permissions: + contents: write + +jobs: + run-bot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Run bot script + env: + CHANGE_INSTRUCTION: ${{ github.event.inputs.change }} + run: | + mkdir -p scripts + echo 'import os, pathlib' > scripts/auto_edit.py + echo 'instr = os.environ.get("CHANGE_INSTRUCTION","(no instruction)")' >> scripts/auto_edit.py + echo 'p = pathlib.Path("BOT_CHANGES.md")' >> scripts/auto_edit.py + echo 'p.write_text(p.read_text() + f"- {instr}\n" if p.exists() else f"- {instr}\n")' >> scripts/auto_edit.py + python3 scripts/auto_edit.py + git config user.name "github-actions" + git config user.email "actions@github.com" + git add BOT_CHANGES.md + git commit -m "bot: apply change ${{ github.event.inputs.change }}" || echo "No changes to commit" + git push From ca69d1339181f4d5baa4b16e47084d1bd5452ab9 Mon Sep 17 00:00:00 2001 From: Brett Gregson Date: Tue, 4 Nov 2025 11:28:53 +0100 Subject: [PATCH 2/4] Update bot-change.yml --- .github/workflows/bot-change.yml | 46 +++++++++++--------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/.github/workflows/bot-change.yml b/.github/workflows/bot-change.yml index b4d00d2b32d..9851ab3ae8a 100644 --- a/.github/workflows/bot-change.yml +++ b/.github/workflows/bot-change.yml @@ -1,39 +1,23 @@ -name: Bot change from input -on: - workflow_dispatch: - inputs: - change: - description: 'Short instruction for the bot' - required: true - -permissions: - contents: write - -jobs: - run-bot: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Run bot script + - name: Run copy-edit bot env: CHANGE_INSTRUCTION: ${{ github.event.inputs.change }} run: | mkdir -p scripts - echo 'import os, pathlib' > scripts/auto_edit.py - echo 'instr = os.environ.get("CHANGE_INSTRUCTION","(no instruction)")' >> scripts/auto_edit.py - echo 'p = pathlib.Path("BOT_CHANGES.md")' >> scripts/auto_edit.py - echo 'p.write_text(p.read_text() + f"- {instr}\n" if p.exists() else f"- {instr}\n")' >> scripts/auto_edit.py + cat <<'PY' > scripts/auto_edit.py +import pathlib +search_text = "Add React to an Existing Project" +replace_text = "Add React to your Existing Project" + +# loop through all .md files in the repo +for md_file in pathlib.Path('.').rglob('*.md'): + content = md_file.read_text() + if search_text in content: + md_file.write_text(content.replace(search_text, replace_text)) + print(f"Updated {md_file}") +PY python3 scripts/auto_edit.py git config user.name "github-actions" git config user.email "actions@github.com" - git add BOT_CHANGES.md - git commit -m "bot: apply change ${{ github.event.inputs.change }}" || echo "No changes to commit" + git add . + git commit -m "bot: apply copy edit" || echo "No changes to commit" git push From ffc622409b38dc628b89f724f6250214dc310bfc Mon Sep 17 00:00:00 2001 From: Brett Gregson Date: Tue, 4 Nov 2025 14:44:22 +0100 Subject: [PATCH 3/4] "Claude PR Assistant workflow" --- .github/workflows/claude.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/claude.yml diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 00000000000..ae36c007f36 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,50 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read + + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options + # claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)' + From 062f13fd964a268906ed1c22fba8c225a99e3a17 Mon Sep 17 00:00:00 2001 From: Brett Gregson Date: Tue, 4 Nov 2025 14:44:24 +0100 Subject: [PATCH 4/4] "Claude Code Review workflow" --- .github/workflows/claude-code-review.yml | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/claude-code-review.yml diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 00000000000..4caf96a2fa4 --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,54 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + prompt: | + Please review this pull request and provide feedback on: + - Code quality and best practices + - Potential bugs or issues + - Performance considerations + - Security concerns + - Test coverage + + Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. + + Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. + + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options + claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"' +