-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (72 loc) · 3.19 KB
/
Copy pathclaude.yml
File metadata and controls
77 lines (72 loc) · 3.19 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
69
70
71
72
73
74
75
76
77
name: Claude
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read
jobs:
claude:
# Trust gate (load-bearing): this job runs from the default branch WITH secrets,
# contents: write, and a checkout of the PR head — comment/issue events are NOT
# protected by the fork-PR "require approval" gate, so without this check ANY
# non-bot user who types "@claude" could trigger a privileged, write-capable run.
#
# The association MUST be checked against the actor of the *firing* event — the
# commenter for *_comment, the reviewer for pull_request_review, the issue
# author for issues. An issue_comment payload carries BOTH `comment` and
# `issue`, so a blanket OR across them lets an untrusted commenter pass via the
# trusted issue author on a maintainer-owned issue/PR. So each event clause
# binds its own actor's association inline.
if: |
github.event.sender.type != 'Bot'
&& (
(github.event_name == 'issue_comment'
&& contains(github.event.comment.body, '@claude')
&& (github.event.comment.author_association == 'OWNER'
|| github.event.comment.author_association == 'MEMBER'
|| github.event.comment.author_association == 'COLLABORATOR')) ||
(github.event_name == 'pull_request_review_comment'
&& contains(github.event.comment.body, '@claude')
&& (github.event.comment.author_association == 'OWNER'
|| github.event.comment.author_association == 'MEMBER'
|| github.event.comment.author_association == 'COLLABORATOR')) ||
(github.event_name == 'pull_request_review'
&& contains(github.event.review.body, '@claude')
&& (github.event.review.author_association == 'OWNER'
|| github.event.review.author_association == 'MEMBER'
|| github.event.review.author_association == 'COLLABORATOR')) ||
(github.event_name == 'issues'
&& (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))
&& (github.event.issue.author_association == 'OWNER'
|| github.event.issue.author_association == 'MEMBER'
|| github.event.issue.author_association == 'COLLABORATOR'))
)
runs-on: ubuntu-latest
steps:
- name: Resolve PR head SHA on issue_comment
id: pr-ref
if: github.event_name == 'issue_comment' && github.event.issue.pull_request != null
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SHA=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}" --jq .head.sha)
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ steps.pr-ref.outputs.sha || github.ref }}
fetch-depth: 1
- name: Run Claude Code
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}