We want to be able to write the clod code review to multiple locations, not just commenting on a pull request, but also commenting directly on a commit or even just writing the review to stdout.
Claude Code's summary after writing the code:
New Features Added:
- Action Inputs (action.yml):
- output_mode: Comma-separated list supporting pr_comment, commit_comment, stdout
- commit_sha: Optional specific commit SHA for commit comments
- Strategy Pattern Architecture:
- OutputStrategy interface for consistent implementation
- PrCommentStrategy: Existing PR/issue comment logic (refactored)
- CommitCommentStrategy: Creates comments on specific commits
- StdoutStrategy: Outputs to workflow logs in plain text format
- OutputManager Class:
- Parses and validates output mode configurations
- Handles multiple output strategies simultaneously
- Provides error resilience (continues if some strategies fail)
- Maintains backward compatibility
- Updated Entry Points:
- prepare.ts: Uses OutputManager for initial tracking
- update-comment-link.ts: Uses OutputManager for final results
Key Features:
✅ Backward Compatibility: Default output_mode: "pr_comment" preserves existing behavior
✅ Flexible Configuration:
- output_mode: "pr_comment" - Traditional PR comments (default)
- output_mode: "commit_comment" - Comments on specific commits
- output_mode: "stdout" - Plain text output to workflow logs
- output_mode: "pr_comment,stdout" - Multiple outputs simultaneously
✅ Smart Commit Resolution:
- Uses explicit commit_sha if provided
- Falls back to PR HEAD commit
- Falls back to workflow commit SHA
✅ Error Handling: Individual strategy failures don't break the entire action
✅ Context Validation: Ensures output modes are valid for the GitHub context
The implementation successfully makes the GitHub Action's review output more general and configurable while maintaining full backward
compatibility.