Skip to content

Add Claude Code GitHub Workflow - #6

Merged
imsyy merged 3 commits into
devfrom
add-claude-github-actions-1776346331261
Apr 16, 2026
Merged

imsyy merged 3 commits into
devfrom
add-claude-github-actions-1776346331261

Conversation

@imsyy

@imsyy imsyy commented Apr 16, 2026

Copy link
Copy Markdown
Member

🤖 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

What is Claude Code?

Claude Code is an AI coding agent that can help with:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

Important Notes

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

There's more information in the Claude Code action repo.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

Copilot AI review requested due to automatic review settings April 16, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GitHub Actions workflows to integrate Anthropic Claude Code into the repository, enabling automated agent runs based on PR/issue activity.

Changes:

  • Add an “@claude”-triggered workflow for issue/PR comments and reviews.
  • Add an automatic PR workflow to run a Claude Code review plugin on PR events.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
.github/workflows/claude.yml Introduces the comment/review/issue-event triggered Claude Code workflow.
.github/workflows/claude-code-review.yml Introduces an always-on Claude-based PR review workflow triggered on PR lifecycle events.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +19
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow can be triggered by any user who can create an issue/comment/review containing “@claude”. Because this job uses a repo secret (CLAUDE_CODE_OAUTH_TOKEN), this effectively allows untrusted users (e.g., first-time issue creators or fork PR authors) to trigger secret-backed runs. Add an explicit trust gate (e.g., restrict to OWNER/MEMBER/COLLABORATOR author_association, or check repo write permissions via the GitHub API) and consider dropping the issues trigger (opened/assigned) entirely to avoid secret exposure from issue titles/bodies.

Suggested change
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(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'))

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +24
pull-requests: read
issues: read

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job-level permissions are read-only for issues and pull-requests, so this workflow will not be able to post PR/issue comments or apply changes using the default GITHUB_TOKEN. Either update the permissions to the minimum required write scopes for the intended behavior (commenting/committing), or clarify in the workflow/PR description that this is intended to be read-only analysis.

Suggested change
pull-requests: read
issues: read
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +11
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says the workflow is triggered by mentioning @claude in a PR/issue comment, but this workflow also triggers on issues events (opened/assigned) if the issue title/body contains @claude. If that’s not intended, remove the issues trigger; if it is intended, please update the PR description/security notes accordingly since it changes who/what can initiate a run.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +6
on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow runs automatically on every PR open/sync/reopen/ready_for_review, which is broader than the PR description (which describes opt-in execution via “@claude” mentions). If this should be opt-in (to control cost/noise), add an if: gate (label/author association), or narrow triggers/paths; otherwise update the PR description to reflect the always-on review behavior.

Copilot uses AI. Check for mistakes.

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both workflows reference anthropics/claude-code-action@v1 (a moving tag). For a third-party action that will run with secrets available, pin to a specific commit SHA (or a version tag plus @<sha> pattern) to reduce supply-chain risk from upstream tag changes.

Suggested change
uses: anthropics/claude-code-action@v1
uses: anthropics/claude-code-action@0123456789abcdef0123456789abcdef01234567

Copilot uses AI. Check for mistakes.

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow also uses a moving tag (anthropics/claude-code-action@v1). Since it may run with secrets available, consider pinning to a commit SHA to mitigate supply-chain risk from upstream tag retargeting.

Suggested change
uses: anthropics/claude-code-action@v1
uses: anthropics/claude-code-action@<FULL_LENGTH_COMMIT_SHA> # pin to the reviewed v1 revision

Copilot uses AI. Check for mistakes.
@imsyy
imsyy merged commit 4a696c3 into dev Apr 16, 2026
2 checks passed
@imsyy
imsyy deleted the add-claude-github-actions-1776346331261 branch April 16, 2026 13:43
roarrabbit pushed a commit to roarrabbit/SPlayer-Next that referenced this pull request Aug 27, 2026
…ctions-1776346331261

Add Claude Code GitHub Workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants