Skip to content

Commit ea88e46

Browse files
authored
Merge pull request #113 from AdjectiveAllison/claude_code_ci_another_one
ci fixes for claude code
2 parents bdd8d9b + 3bc75c4 commit ea88e46

File tree

3 files changed

+48
-145
lines changed

3 files changed

+48
-145
lines changed
Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Claude Code Review
22

33
on:
4-
pull_request_target: # Use pull_request_target instead of pull_request
4+
pull_request:
55
types: [opened, synchronize] # Runs on new PRs and updates
66

77
jobs:
@@ -11,47 +11,22 @@ jobs:
1111
contents: read
1212
pull-requests: write
1313
issues: write
14-
discussions: write
1514
id-token: write
16-
statuses: write
17-
actions: write
1815
steps:
19-
# Check out the code to allow git diff operations
16+
# Simply checking out the repository is sufficient - the action handles the PR code
2017
- name: Checkout code
2118
uses: actions/checkout@v4
2219
with:
23-
fetch-depth: 0 # Fetch full history for accurate diffs
24-
# Important: For pull_request_target, ref needs to be explicitly set to PR head
25-
ref: ${{ github.event.pull_request.head.sha }}
20+
fetch-depth: 0 # Get full history for accurate diffs
2621

2722
- name: Run Code Review with Claude
28-
id: code-review
2923
uses: anthropics/claude-code-action@beta
3024
with:
31-
# Define the review focus areas
32-
direct_prompt: "Review the PR changes. Focus on code quality, potential bugs, and performance issues. Suggest improvements where appropriate. Pay special attention to Kubernetes operator patterns and Go best practices according to the CLAUDE.md file."
33-
34-
# Your GitHub token for API operations
35-
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
# Your Anthropic API key
26+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3627

37-
# Limited tools for safer review operations
38-
allowed_tools: |-
39-
# Git inspection commands (read-only)
40-
Bash(git status)
41-
Bash(git log)
42-
Bash(git diff --name-only HEAD~1)
43-
Bash(git diff HEAD~1)
44-
Bash(git show)
45-
Bash(git blame)
46-
47-
# File exploration tools
48-
View # Read file contents
49-
GlobTool # Find files by pattern
50-
GrepTool # Search file contents
51-
BatchTool # Run multiple tools in parallel
52-
53-
# Timeout after 15 minutes
54-
timeout_minutes: 15
28+
# Direct prompt for Claude to execute
29+
direct_prompt: "Review the PR changes. Focus on code quality, potential bugs, and performance issues. Suggest improvements where appropriate. Pay special attention to Kubernetes operator patterns and Go best practices according to the CLAUDE.md file."
5530

56-
# Your Anthropic API key (stored as a GitHub secret)
57-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
31+
# Timeout for execution
32+
timeout_minutes: 15

.github/workflows/claude-comment-response.yml

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,23 @@ jobs:
1212
contents: write
1313
pull-requests: write
1414
issues: write
15-
discussions: write
1615
id-token: write
17-
statuses: write
18-
actions: write
1916
steps:
17+
# Simply checking out the repository is sufficient
2018
- name: Checkout code
2119
uses: actions/checkout@v4
2220
with:
23-
fetch-depth: 0 # Fetch full history for accurate diffs
24-
25-
# If running on a PR comment, we need to explicitly check out the PR branch
26-
- name: Checkout PR branch if needed
27-
if: github.event.issue.pull_request
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
run: |
31-
# Get the PR number from the issue object
32-
PR_NUMBER="${{ github.event.issue.number }}"
33-
34-
echo "Checking out PR #${PR_NUMBER}"
35-
36-
# Get PR info
37-
PR_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
38-
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")
39-
40-
# Extract the PR branch ref and other details
41-
PR_BRANCH=$(echo "$PR_INFO" | jq -r .head.ref)
42-
PR_SHA=$(echo "$PR_INFO" | jq -r .head.sha)
43-
PR_REPO=$(echo "$PR_INFO" | jq -r .head.repo.full_name)
44-
45-
echo "PR branch is $PR_BRANCH from repo $PR_REPO with commit SHA $PR_SHA"
46-
47-
# Fetch the PR as a local branch (works for forks too)
48-
git fetch origin "pull/$PR_NUMBER/head:pr-$PR_NUMBER"
49-
git checkout "pr-$PR_NUMBER"
50-
51-
# Verify checkout
52-
echo "Current branch details:"
53-
git status
54-
git rev-parse HEAD
21+
fetch-depth: 0 # Get full history for accurate diffs
5522

5623
- name: Claude Response
5724
uses: anthropics/claude-code-action@beta
5825
with:
59-
# Your GitHub token for API operations
60-
github_token: ${{ secrets.GITHUB_TOKEN }}
61-
62-
# Pass the comment text as the prompt
63-
direct_prompt: "${{ github.event.comment.body }}"
64-
65-
# Define which tools Claude can use
66-
allowed_tools: |-
67-
# Git inspection commands (read-only)
68-
Bash(git status)
69-
Bash(git log)
70-
Bash(git show)
71-
Bash(git blame)
72-
Bash(git ls-files)
73-
Bash(git branch)
74-
Bash(git tag)
75-
Bash(git diff)
76-
77-
# File modifications
78-
Bash(git add)
79-
Bash(git commit)
80-
81-
# File exploration tools
82-
View # Read file contents
83-
Edit # Edit files
84-
GlobTool # Find files by pattern
85-
GrepTool # Search file contents
86-
BatchTool # Run multiple tools in parallel
26+
# Your Anthropic API key
27+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
8728

88-
# Timeout after 20 minutes
89-
timeout_minutes: 20
29+
# Explicitly set the trigger phrase and provide github token
30+
trigger_phrase: "@claude"
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
9032

91-
# Your Anthropic API key (stored as a GitHub secret)
92-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
33+
# Timeout for execution
34+
timeout_minutes: 20

.github/workflows/claude-pr-creation.yml

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
create-pr:
9-
# Only run if the comment mentions @claude create pr or similar
9+
# Only run if the comment mentions specific PR creation prompts
1010
if: >
1111
contains(github.event.comment.body, '@claude create pr') ||
1212
contains(github.event.comment.body, '@claude create a pr') ||
@@ -17,58 +17,44 @@ jobs:
1717
contents: write
1818
pull-requests: write
1919
issues: write
20-
discussions: write
2120
id-token: write
22-
statuses: write
23-
actions: write
2421
steps:
22+
# Simply checking out the repository is sufficient
2523
- name: Checkout code
2624
uses: actions/checkout@v4
2725
with:
2826
fetch-depth: 0 # Fetch full history for accurate diffs
2927

28+
# If running on a PR comment, we need to explicitly check out the PR branch
29+
- name: Checkout PR branch if needed
30+
if: github.event.issue.pull_request
31+
run: |
32+
# Get the PR number from the issue object
33+
PR_NUMBER="${{ github.event.issue.number }}"
34+
echo "Fetching PR #${PR_NUMBER} details..."
35+
36+
# Use the GitHub CLI to get PR details
37+
gh pr view "$PR_NUMBER" --json headRefName,headRepository --jq '.headRefName, .headRepository.nameWithOwner'
38+
39+
# Checkout the PR using the GitHub CLI - this handles forks automatically
40+
echo "Checking out PR #${PR_NUMBER}..."
41+
gh pr checkout $PR_NUMBER
42+
43+
echo "Current branch details:"
44+
git status
45+
git branch
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
3049
- name: Claude PR Creation
3150
uses: anthropics/claude-code-action@beta
3251
with:
33-
# Your GitHub token for API operations
34-
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
# Your Anthropic API key
53+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3554

36-
# Pass the comment text as the prompt
37-
direct_prompt: "${{ github.event.comment.body }}"
38-
39-
# Define which tools Claude can use
40-
allowed_tools: |-
41-
# Git inspection commands
42-
Bash(git status)
43-
Bash(git log)
44-
Bash(git show)
45-
Bash(git blame)
46-
Bash(git reflog)
47-
Bash(git stash list)
48-
Bash(git ls-files)
49-
Bash(git branch)
50-
Bash(git tag)
51-
Bash(git diff)
52-
53-
# Git modification commands
54-
Bash(git checkout -b)
55-
Bash(git add)
56-
Bash(git commit)
57-
Bash(git push)
58-
59-
# GitHub CLI commands for PR creation
60-
Bash(gh pr create)
61-
62-
# File exploration and modification tools
63-
View # Read file contents
64-
Edit # Edit files
65-
GlobTool # Find files by pattern
66-
GrepTool # Search file contents
67-
BatchTool # Run multiple tools in parallel
68-
69-
70-
# Timeout after 30 minutes for potentially complex implementations
71-
timeout_minutes: 30
55+
# Explicitly set the trigger phrase and provide github token
56+
trigger_phrase: "@claude"
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
7258

73-
# Your Anthropic API key (stored as a GitHub secret)
74-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
59+
# Timeout for execution (longer for PR creation)
60+
timeout_minutes: 30

0 commit comments

Comments
 (0)