2 Commits

Author SHA1 Message Date
Bas
98854f172d "Claude Code Review workflow" 2025-08-31 18:17:25 +02:00
Bas
1e76d456fc "Claude PR Assistant workflow" 2025-08-31 18:17:24 +02:00
7 changed files with 113 additions and 108 deletions

View File

@@ -0,0 +1,54 @@
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

50
.github/workflows/claude.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
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')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'
# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@xtr-dev/payload-workflows",
"version": "0.0.13",
"version": "0.0.11",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@xtr-dev/payload-workflows",
"version": "0.0.13",
"version": "0.0.11",
"license": "MIT",
"dependencies": {
"jsonpath-plus": "^10.3.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@xtr-dev/payload-automation",
"version": "0.0.13",
"version": "0.0.11",
"description": "PayloadCMS Automation Plugin - Comprehensive workflow automation system with visual workflow building, execution tracking, and step types",
"license": "MIT",
"type": "module",

View File

@@ -606,12 +606,6 @@ export class WorkflowExecutor {
previousDoc: unknown,
req: PayloadRequest
): Promise<void> {
this.logger.info({
collection,
operation,
docId: (doc as any)?.id
}, 'executeTriggeredWorkflows called')
try {
// Find workflows with matching triggers
const workflows = await this.payload.find({
@@ -620,46 +614,21 @@ export class WorkflowExecutor {
limit: 100,
req
})
this.logger.info({
workflowCount: workflows.docs.length
}, 'Found workflows to check')
for (const workflow of workflows.docs) {
// Check if this workflow has a matching trigger
const triggers = workflow.triggers as Array<{
collection?: string
collectionSlug?: string
collection: string
condition?: string
operation: string
type: string
}>
this.logger.debug({
workflowId: workflow.id,
workflowName: workflow.name,
triggerCount: triggers?.length || 0,
triggers: triggers?.map(t => ({
type: t.type,
collection: t.collection,
collectionSlug: t.collectionSlug,
operation: t.operation
}))
}, 'Checking workflow triggers')
const matchingTriggers = triggers?.filter(trigger =>
trigger.type === 'collection-trigger' &&
(trigger.collection === collection || trigger.collectionSlug === collection) &&
trigger.collection === collection &&
trigger.operation === operation
) || []
this.logger.info({
workflowId: workflow.id,
workflowName: workflow.name,
matchingTriggerCount: matchingTriggers.length,
targetCollection: collection,
targetOperation: operation
}, 'Matching triggers found')
for (const trigger of matchingTriggers) {
// Create execution context for condition evaluation

View File

@@ -1,16 +1,10 @@
// Main export contains only types and client-safe utilities
// Server-side functions are exported via '@xtr-dev/payload-automation/server'
// Pure types only - completely safe for client bundling
export type {
CustomTriggerOptions,
TriggerResult,
ExecutionContext,
Workflow,
WorkflowStep,
WorkflowTrigger,
WorkflowsPluginConfig
} from './types/index.js'
// Types only - safe for client bundling
export type { CustomTriggerOptions, TriggerResult } from './core/trigger-custom-workflow.js'
export type { ExecutionContext, Workflow, WorkflowStep, WorkflowTrigger } from './core/workflow-executor.js'
export type { WorkflowsPluginConfig } from './plugin/config-types.js'
// Server-side functions are NOT re-exported here to avoid bundling issues
// Import server-side functions from the /server export instead

View File

@@ -1,62 +0,0 @@
// Pure type definitions for client-safe exports
// This file contains NO runtime code and can be safely bundled
export interface CustomTriggerOptions {
workflowId: string
triggerData?: any
req?: any // PayloadRequest type, but avoiding import to keep this client-safe
}
export interface TriggerResult {
success: boolean
runId?: string
error?: string
}
export interface ExecutionContext {
trigger: {
type: string
doc?: any
data?: any
}
steps: Record<string, {
output?: any
state: 'pending' | 'running' | 'succeeded' | 'failed'
}>
payload: any // Payload instance
req: any // PayloadRequest
}
export interface WorkflowStep {
id: string
type: string
input: Record<string, any>
dependencies?: string[]
}
export interface WorkflowTrigger {
type: 'collection' | 'global' | 'webhook' | 'cron' | 'manual'
collection?: string
global?: string
event?: 'create' | 'update' | 'delete' | 'read'
path?: string
cron?: string
}
export interface Workflow {
id: string
name: string
description?: string
active: boolean
triggers: WorkflowTrigger[]
steps: WorkflowStep[]
}
export interface WorkflowsPluginConfig {
collections?: string[]
globals?: string[]
logging?: {
level?: 'debug' | 'info' | 'warn' | 'error'
enabled?: boolean
}
}