Skip to content

Commit e389428

Browse files
Add Claude Code GitHub Actions workflows (#7)
* Add Claude Code GitHub Actions workflows Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: track major-version action tags instead of pinned SHAs Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: drop concurrency limit from the @claude workflow Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 891f817 commit e389428

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Claude Code Review
2+
3+
# Runs on PRs INTO this repo. We use pull_request_target (not pull_request) so
4+
# that PRs from a fork can access CLAUDE_CODE_OAUTH_TOKEN — GitHub withholds
5+
# secrets from `pull_request` runs triggered by forks, which is why the plain
6+
# `pull_request` version never worked for fork PRs.
7+
#
8+
# SECURITY: pull_request_target runs in the BASE repo with secrets and a
9+
# write-capable token. The job is gated to PRs from the trusted `jnasbyupgrade`
10+
# fork only — an arbitrary external fork can never trigger this secret-bearing
11+
# job. The workflow file always comes from the base branch (master), so a PR
12+
# cannot modify the reviewer that runs on it. We check out the PR head only for
13+
# read context (persist-credentials: false) and never build or execute PR code.
14+
on:
15+
pull_request_target:
16+
types: [opened, synchronize, reopened, ready_for_review]
17+
18+
concurrency:
19+
group: claude-review-${{ github.event.pull_request.number }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
claude-review:
24+
# Trusted fork only, and skip drafts (don't spend API/CI on unfinished PRs).
25+
# To add more trusted owners, extend the head-owner check.
26+
if: >-
27+
github.event.pull_request.draft == false &&
28+
github.event.pull_request.head.repo.owner.login == 'jnasbyupgrade'
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 30
31+
permissions:
32+
contents: read
33+
pull-requests: write # post the review comments
34+
id-token: write
35+
steps:
36+
- name: Check out PR head (read-only context)
37+
# Intentionally tracks the major-version tag (not a pinned SHA) so
38+
# upstream fixes are picked up automatically.
39+
uses: actions/checkout@v4
40+
with:
41+
repository: ${{ github.event.pull_request.head.repo.full_name }}
42+
ref: ${{ github.event.pull_request.head.sha }}
43+
fetch-depth: 1
44+
persist-credentials: false
45+
46+
- name: Run Claude Code Review
47+
uses: anthropics/claude-code-action@v1
48+
with:
49+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
50+
# NOTE: plugin_marketplaces can't be pinned — it tracks the
51+
# marketplace repo's default branch (upstream anthropics/claude-code).
52+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
53+
plugins: 'code-review@claude-code-plugins'
54+
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'

.github/workflows/claude.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
# No concurrency limit: @claude mentions are independent, read-only requests;
14+
# serializing would only delay responses and cancelling would drop them.
15+
jobs:
16+
claude:
17+
if: |
18+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
19+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 30
24+
permissions:
25+
contents: read
26+
pull-requests: read
27+
issues: read
28+
id-token: write
29+
actions: read # Required for Claude to read CI results on PRs
30+
steps:
31+
- name: Checkout repository
32+
# Intentionally tracks the major-version tag (not a pinned SHA) so
33+
# upstream fixes are picked up automatically.
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 1
37+
persist-credentials: false
38+
39+
- name: Run Claude Code
40+
id: claude
41+
uses: anthropics/claude-code-action@v1
42+
with:
43+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
44+
# Allows Claude to read CI results on PRs
45+
additional_permissions: |
46+
actions: read

0 commit comments

Comments
 (0)