-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathclaude-review-maintainer-prs.yml
More file actions
68 lines (61 loc) · 2.11 KB
/
claude-review-maintainer-prs.yml
File metadata and controls
68 lines (61 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Claude Review on Maintainer PRs
on:
pull_request_target:
types:
- opened
- ready_for_review
jobs:
comment:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Check author permission and existing review request
id: check
uses: actions/github-script@v8
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const issue_number = context.payload.pull_request.number;
const username = context.payload.pull_request.user.login;
let permission = "none";
try {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username,
});
permission = data.permission;
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
const canWrite = ["write", "admin"].includes(permission);
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const hasReviewRequest = comments.some(
(comment) => comment.body?.trim() === "@claude review",
);
core.info(
`PR #${issue_number} by ${username}: permission=${permission}, hasReviewRequest=${hasReviewRequest}`,
);
core.setOutput("should_comment", canWrite && !hasReviewRequest ? "true" : "false");
- name: Add Claude review comment
if: steps.check.outputs.should_comment == 'true'
uses: actions/github-script@v8
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "@claude review",
});