Skip to content

Commit b0417dd

Browse files
michaelmcneesclaude
andcommitted
fix: harden Claude Code workflow — pin SHA, restrict to trusted actors
- Pin anthropics/claude-code-action to immutable commit SHA (094bd24) - Restrict triggers to repo owner, members, and collaborators via author_association checks on each event type - Remove trailing blank line, clean up inline comments - Remove unused optional comments for cleaner config Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b39921a commit b0417dd

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

.github/workflows/claude.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ on:
1313
jobs:
1414
claude:
1515
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')))
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
17+
(github.event.comment.user.login == github.repository_owner || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')) ||
18+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
19+
(github.event.comment.user.login == github.repository_owner || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
21+
(github.event.review.user.login == github.repository_owner || github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'COLLABORATOR')) ||
22+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
23+
(github.event.issue.user.login == github.repository_owner || github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'COLLABORATOR'))
2024
runs-on: ubuntu-latest
2125
permissions:
2226
contents: read
2327
pull-requests: read
2428
issues: read
2529
id-token: write
26-
actions: read # Required for Claude to read CI results on PRs
30+
actions: read
2731
steps:
2832
- name: Checkout repository
2933
uses: actions/checkout@v4
@@ -32,19 +36,8 @@ jobs:
3236

3337
- name: Run Claude Code
3438
id: claude
35-
uses: anthropics/claude-code-action@v1
39+
uses: anthropics/claude-code-action@094bd24d575e7b30ac1576024817bf1a97c81262 # v1
3640
with:
3741
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38-
39-
# This is an optional setting that allows Claude to read CI results on PRs
4042
additional_permissions: |
4143
actions: read
42-
43-
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44-
# prompt: 'Update the pull request description to include a summary of changes.'
45-
46-
# Optional: Add claude_args to customize behavior and configuration
47-
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48-
# or https://code.claude.com/docs/en/cli-reference for available options
49-
# claude_args: '--allowed-tools Bash(gh pr:*)'
50-

0 commit comments

Comments
 (0)