Skip to content

Claude Code

Claude Code #69

Workflow file for this run

name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
check-team-membership:
runs-on: ubuntu-latest
outputs:
is-team-member: ${{ steps.check-membership.outputs.is-member }}
steps:
- name: Check team membership
id: check-membership
uses: actions/github-script@v8
with:
script: |
try {
// Get username - prioritize sender (the person who triggered the event)
const username = github.event?.sender?.login ||
github.event?.comment?.user?.login;
if (!username) {
console.log('Could not determine username from event payload');
console.log(`Event type: ${github.event_name}`);
console.log(`Event payload keys: ${Object.keys(github.event).join(', ')}`);
return false;
}
console.log(`Checking team membership for user: ${username} (triggered by ${github.event_name} event)`);
const { data } = await github.rest.teams.getMembershipForUserInOrg({
org: 'diffplug',
team_slug: 'spotless',
username: username
});
console.log(`User ${username} membership status: ${data.state}`);
return data.state === 'active';
} catch (error) {
const username = github.event.sender?.login || github.event.comment?.user?.login || 'unknown user';
console.log(`User ${username} is not a member of the Spotless team or error occurred: ${error.message}`);
return false;
}
claude:
needs: check-team-membership
if: |
needs.check-team-membership.outputs.is-team-member == 'true' &&
(
(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')))
)
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}