Skip to content

Commit 85b8b44

Browse files
kirich1409claude
andcommitted
fix: address PR review comments for Claude workflow
- Add author_association check (OWNER/MEMBER/COLLABORATOR only) - Remove id-token: write permission (not needed) - Remove fetch-depth: 1, add dynamic ref detection for PR contexts - Add chmod +x gradlew step before Gradle commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 711e51b commit 85b8b44

1 file changed

Lines changed: 45 additions & 7 deletions

File tree

‎.github/workflows/claude.yml‎

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,58 @@ on:
1212

1313
jobs:
1414
claude:
15+
# Only allow trusted collaborators to trigger Claude via @claude mention
1516
if: |
16-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
17+
(
18+
github.event.comment.author_association == 'OWNER' ||
19+
github.event.comment.author_association == 'MEMBER' ||
20+
github.event.comment.author_association == 'COLLABORATOR' ||
21+
github.event.review.author_association == 'OWNER' ||
22+
github.event.review.author_association == 'MEMBER' ||
23+
github.event.review.author_association == 'COLLABORATOR' ||
24+
github.event.issue.author_association == 'OWNER' ||
25+
github.event.issue.author_association == 'MEMBER' ||
26+
github.event.issue.author_association == 'COLLABORATOR'
27+
) && (
28+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
29+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
30+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
31+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
32+
)
2033
runs-on: ubuntu-latest
2134
permissions:
2235
contents: write
2336
pull-requests: write
2437
issues: write
25-
id-token: write
26-
actions: read # Required for Claude to read CI results on PRs
38+
actions: read
2739
steps:
40+
- name: Determine checkout ref
41+
id: determine-ref
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const eventName = context.eventName;
47+
let ref = context.sha;
48+
49+
if (eventName === 'pull_request_review' || eventName === 'pull_request_review_comment') {
50+
ref = context.payload.pull_request.head.sha;
51+
} else if (eventName === 'issue_comment' && context.payload.issue && context.payload.issue.pull_request) {
52+
const prNumber = context.payload.issue.number;
53+
const { data: pr } = await github.rest.pulls.get({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
pull_number: prNumber,
57+
});
58+
ref = pr.head.sha;
59+
}
60+
61+
core.setOutput('ref', ref);
62+
2863
- name: Checkout repository
2964
uses: actions/checkout@v6
3065
with:
31-
fetch-depth: 1
66+
ref: ${{ steps.determine-ref.outputs.ref }}
3267

3368
- name: Set up JDK 21
3469
uses: actions/setup-java@v5
@@ -37,6 +72,9 @@ jobs:
3772
distribution: 'temurin'
3873
cache: gradle
3974

75+
- name: Grant execute permission for gradlew
76+
run: chmod +x gradlew
77+
4078
- name: Setup Gradle
4179
uses: gradle/actions/setup-gradle@v4
4280

0 commit comments

Comments
 (0)