Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions .github/workflows/claude-orchestrator.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Claude Orchestrator Workflow (Reusable) - FIXED
# Claude Orchestrator Workflow (Reusable)
#
# PURPOSE: This workflow orchestrates Claude AI interactions by providing
# a simple, reliable interface to the claude-executor. Consumer repositories
Expand Down Expand Up @@ -45,12 +45,58 @@ on:
required: false
type: string
default: 'ubuntu-latest'
enable_mention_detection:
description: 'Enable automatic @claude mention detection for interactive mode'
required: false
type: boolean
default: true
custom_trigger_condition:
description: 'Custom condition to override default mention detection (optional)'
required: false
type: string
secrets:
ANTHROPIC_API_KEY:
required: true

jobs:
claude-execution:
# Only run if custom condition is provided OR default mention detection is enabled and mentions are found
if: |
inputs.custom_trigger_condition != '' || (
inputs.enable_mention_detection == true && inputs.trigger_mode == 'interactive' && (
(github.event_name == 'issue_comment' && (
contains(github.event.comment.body, '@claude') ||
contains(github.event.comment.body, '@Claude') ||
contains(github.event.comment.body, '@CLAUDE')
)) ||
(github.event_name == 'pull_request_review_comment' && (
contains(github.event.comment.body, '@claude') ||
contains(github.event.comment.body, '@Claude') ||
contains(github.event.comment.body, '@CLAUDE')
)) ||
(github.event_name == 'pull_request_review' && (
contains(github.event.review.body, '@claude') ||
contains(github.event.review.body, '@Claude') ||
contains(github.event.review.body, '@CLAUDE')
)) ||
(github.event_name == 'issues' && (
contains(github.event.issue.body, '@claude') ||
contains(github.event.issue.body, '@Claude') ||
contains(github.event.issue.body, '@CLAUDE') ||
contains(github.event.issue.title, '@claude') ||
contains(github.event.issue.title, '@Claude') ||
contains(github.event.issue.title, '@CLAUDE')
)) ||
(github.event_name == 'pull_request' && (
contains(github.event.pull_request.title, '@claude') ||
contains(github.event.pull_request.title, '@Claude') ||
contains(github.event.pull_request.title, '@CLAUDE') ||
contains(github.event.pull_request.body, '@claude') ||
contains(github.event.pull_request.body, '@Claude') ||
contains(github.event.pull_request.body, '@CLAUDE')
))
)
) || inputs.trigger_mode == 'automatic'
uses: ./.github/workflows/claude-executor.yml
with:
trigger_mode: ${{ inputs.trigger_mode }}
Expand All @@ -59,4 +105,4 @@ jobs:
timeout_minutes: ${{ inputs.timeout_minutes }}
runner: ${{ inputs.runner }}
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
110 changes: 97 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ If you previously used the pilot Claude workflow in `dotcms/infrastructure-as-co
claude:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic # or 'interactive' for @claude mentions
# Customize as needed for your repo
allowed_tools: |
Bash(terraform plan)
Bash(git status)
automatic_review_prompt: |
direct_prompt: |
Please review this pull request for code quality, security, and best practices.
enable_mention_detection: true # Enable @claude mention detection
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
```
Expand Down Expand Up @@ -96,7 +98,7 @@ flowchart TD
## Available Workflows

### Claude Orchestrator (`claude-orchestrator.yml`)
Routes all Claude triggers (PRs, issues, comments, reviews) to the correct execution mode and statically calls the executor workflow.
Routes all Claude triggers (PRs, issues, comments, reviews) to the correct execution mode. Features built-in @claude mention detection and support for custom trigger conditions.

### Claude Executor (`claude-executor.yml`)
Handles the actual execution of Claude actions, with configurable parameters (prompts, allowed tools, runner, etc.).
Expand All @@ -117,24 +119,45 @@ Each consuming repository must configure its own Anthropic API key:
Create a workflow file in your repository at `.github/workflows/claude-review.yml` (or similar):

```yaml
name: PR Code Review with Claude
name: Claude AI Integration

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
pull_request:
types: [opened, synchronize, reopened]
branches: [ main, develop ]
types: [opened, synchronize]

jobs:
claude:
# Interactive Claude mentions using built-in detection
claude-interactive:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
# Optional: Customize allowed tools
trigger_mode: interactive
allowed_tools: |
Bash(terraform plan)
Bash(git status)
# Optional: Customize review prompt
automatic_review_prompt: |
Bash(git diff)
enable_mention_detection: true # Uses built-in @claude detection
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

# Automatic PR reviews (no @claude mention required)
claude-automatic:
if: github.event_name == 'pull_request'
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic
direct_prompt: |
Please review this pull request for code quality, security, and best practices.
allowed_tools: |
Bash(git status)
Bash(git diff)
enable_mention_detection: false # No mention detection for automatic reviews
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
```
Expand All @@ -143,13 +166,74 @@ jobs:

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `automatic_review_prompt` | Custom prompt for automatic PR reviews | No | See orchestrator default |
| `allowed_tools` | Custom allowed tools configuration | No | See orchestrator default |
| `trigger_mode` | Mode: `interactive` or `automatic` | **Yes** | - |
| `direct_prompt` | Custom prompt for automatic mode | No | - |
| `allowed_tools` | Custom allowed tools configuration | No | `Bash(git status)`<br>`Bash(git diff)` |
| `timeout_minutes` | Timeout for Claude execution | No | 15 |
| `runner` | GitHub runner to use | No | ubuntu-latest |
| `enable_mention_detection` | Enable built-in @claude mention detection | No | true |
| `custom_trigger_condition` | Custom condition to override default detection | No | - |

### 4. Advanced: Custom Trigger Conditions

For advanced use cases beyond @claude mentions, use `custom_trigger_condition`:

```yaml
jobs:
claude-security-review:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic
custom_trigger_condition: |
github.event_name == 'pull_request' && (
contains(github.event.pull_request.title, 'security') ||
contains(github.event.pull_request.body, 'vulnerability')
)
direct_prompt: |
This appears to be a security-related change. Please review for security implications.
enable_mention_detection: false # Disable default detection when using custom condition
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
```

**Note**: When using `custom_trigger_condition`, set `enable_mention_detection: false` to avoid conflicts.

---

## Examples

See the `examples/` directory for complete workflow examples.
See the `examples/` directory for complete workflow examples:

- **`consumer-repo-workflow.yml`** - Basic usage with @claude mentions
- **`infrastructure-consumer-workflow.yml`** - Infrastructure-specific tooling
- **`advanced-custom-triggers.yml`** - Advanced examples using `custom_trigger_condition` for specialized triggers (urgent issues, security reviews, config changes, etc.)

### Quick Examples

**Basic @claude mention detection:**
```yaml
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: interactive
enable_mention_detection: true
```

**Automatic PR reviews:**
```yaml
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic
direct_prompt: "Review this PR for quality and security."
enable_mention_detection: false
```

**Custom triggers for urgent issues:**
```yaml
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: interactive
custom_trigger_condition: |
github.event_name == 'issues' &&
contains(github.event.issue.labels.*.name, 'urgent')
enable_mention_detection: false
```
129 changes: 129 additions & 0 deletions examples/advanced-custom-triggers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Advanced Custom Trigger Conditions Example
# This example demonstrates using custom_trigger_condition for advanced use cases
# beyond the default @claude mention detection.

name: Advanced Claude Integration with Custom Triggers

# Concurrency control to prevent multiple jobs running for the same PR/issue
concurrency:
group: claude-${{ github.event.pull_request.number || github.event.issue.number || 'manual' }}
cancel-in-progress: false

on:
workflow_dispatch:
inputs:
test_mode:
description: 'Test mode for debugging'
required: false
type: boolean
default: false
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
pull_request:
types: [opened, synchronize]

jobs:
# Example 1: Custom trigger for urgent issues only
claude-urgent-issues:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: interactive
# Custom condition: Only trigger for issues labeled as "urgent" or "critical"
custom_trigger_condition: |
github.event_name == 'issues' && (
contains(github.event.issue.labels.*.name, 'urgent') ||
contains(github.event.issue.labels.*.name, 'critical') ||
contains(github.event.issue.labels.*.name, 'P0')
)
allowed_tools: |
Bash(git status)
Bash(git diff)
timeout_minutes: 10
runner: ubuntu-latest
enable_mention_detection: false # Disable default @claude detection since we have custom logic
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

# Example 2: Custom trigger for specific file changes
claude-config-changes:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic
# Custom condition: Only trigger for PRs that modify configuration files
custom_trigger_condition: |
github.event_name == 'pull_request' && (
contains(github.event.pull_request.title, '[config]') ||
contains(github.event.pull_request.body, 'configuration') ||
github.event.pull_request.changed_files > 10
)
direct_prompt: |
This PR appears to modify configuration files or has many changes.
Please review for:
- Configuration syntax and validity
- Potential breaking changes
- Security implications of config changes
- Impact on existing functionality
allowed_tools: |
Bash(git status)
Bash(git diff)
Bash(grep -r "config" .)
timeout_minutes: 15
runner: ubuntu-latest
enable_mention_detection: false
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

# Example 3: Custom trigger combining multiple conditions
claude-security-review:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: automatic
# Custom condition: Security-related changes or mentions
custom_trigger_condition: |
(github.event_name == 'pull_request' && (
contains(github.event.pull_request.title, 'security') ||
contains(github.event.pull_request.title, 'auth') ||
contains(github.event.pull_request.body, 'vulnerability') ||
contains(github.event.pull_request.body, 'CVE-')
)) ||
(github.event_name == 'issue_comment' && (
contains(github.event.comment.body, 'security review') ||
contains(github.event.comment.body, '@security-team')
))
direct_prompt: |
This appears to be a security-related change. Please provide a thorough security review focusing on:
- Authentication and authorization mechanisms
- Input validation and sanitization
- Potential security vulnerabilities
- Compliance with security best practices
- Impact on existing security controls
allowed_tools: |
Bash(git status)
Bash(git diff)
Bash(grep -r "password\|token\|secret\|key" . --exclude-dir=.git)
timeout_minutes: 20
runner: ubuntu-latest
enable_mention_detection: false
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

# Example 4: Fallback with default @claude mention detection
claude-general:
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
with:
trigger_mode: interactive
# No custom condition - will use default @claude mention detection
allowed_tools: |
Bash(git status)
Bash(git diff)
timeout_minutes: 15
runner: ubuntu-latest
enable_mention_detection: true # Use default @claude mention detection
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Loading