Skip to content

Commit c612628

Browse files
committed
Add separate claude review / claude write actions
Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent e22b906 commit c612628

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/claude-review.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ jobs:
119119
});
120120
pr = response.data;
121121
122-
const isFork = Boolean(pr.head.repo.fork) || pr.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
122+
const headRepo = pr.head.repo;
123+
const isFork = !headRepo || Boolean(headRepo.fork) || headRepo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
123124
core.setOutput('pull_number', String(pullNumber));
124125
core.setOutput('checkout_ref', pr.head.sha);
125126
@@ -132,6 +133,18 @@ jobs:
132133
) {
133134
reason = 'claude_pr_uses_write_workflow';
134135
}
136+
137+
if (!reason) {
138+
const files = await github.paginate(github.rest.pulls.listFiles, {
139+
owner: context.repo.owner,
140+
repo: context.repo.repo,
141+
pull_number: pullNumber,
142+
per_page: 100,
143+
});
144+
if (files.some(f => f.filename.startsWith('.github/'))) {
145+
reason = 'modifies_github_dir';
146+
}
147+
}
135148
}
136149
137150
core.setOutput('actor_has_write', actorHasWrite);
@@ -204,5 +217,5 @@ jobs:
204217
actions: read
205218
206219
claude_args: |
207-
--allowedTools "Read,Grep,Glob,Bash(git diff:*),Bash(git show:*),Bash(git log:*),Bash(cat:*),Bash(head:*),Bash(sed:*),Bash(jq:*),Bash(rg:*)"
220+
--allowedTools "Read,Grep,Glob,Bash(git diff:*),Bash(git show:*),Bash(git log:*),Bash(head:*),Bash(jq:*),Bash(rg:*)"
208221
--system-prompt "You are the repository's read-only Claude review workflow. Review the current same-repo pull request and respond in GitHub. Never modify files, never create commits, never push branches, and never open or update pull requests. Fork pull requests are blocked before this job starts."

.github/workflows/claude-write.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,29 @@ jobs:
9898
});
9999
const pr = response.data;
100100
101-
checkoutRef = pr.head.ref;
101+
checkoutRef = pr.head.sha;
102102
103-
const isFork = Boolean(pr.head.repo.fork) || pr.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
103+
const headRepo = pr.head.repo;
104+
const isFork = !headRepo || Boolean(headRepo.fork) || headRepo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
104105
if (isFork) {
105106
reason = 'fork_pr_refused';
106107
} else if (!trustedClaudeLogin) {
107108
reason = 'missing_claude_app_login';
108109
} else if ((pr.user?.login ?? '') !== trustedClaudeLogin) {
109110
reason = 'pr_not_owned_by_claude_app';
110111
}
112+
113+
if (!reason) {
114+
const files = await github.paginate(github.rest.pulls.listFiles, {
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
pull_number: context.payload.issue.number,
118+
per_page: 100,
119+
});
120+
if (files.some(f => f.filename.startsWith('.github/'))) {
121+
reason = 'modifies_github_dir';
122+
}
123+
}
111124
}
112125
}
113126

0 commit comments

Comments
 (0)