Skip to content

Commit e26a937

Browse files
EdwardAngertclaude
andcommitted
enhance: improve docs-analysis composite action with best practices
Enhanced the docs-analysis composite action with several GitHub Actions best practices: - Added input validation to prevent command injection - Implemented path sanitization for safer file operations - Created retry logic for git operations to handle rate limiting - Enhanced cross-platform compatibility with fallbacks - Added repository size detection with adaptive throttling - Implemented Python integration for safer JSON handling - Added execution time tracking and performance metrics - Created comprehensive documentation with examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 57cec51 commit e26a937

File tree

2 files changed

+516
-180
lines changed

2 files changed

+516
-180
lines changed

.github/actions/docs-analysis/README.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ A composite GitHub Action to analyze documentation changes in pull requests and
66

77
- Detects documentation files changed in a PR
88
- Calculates metrics (files changed, words added/removed)
9-
- Tracks image changes (added, modified, deleted)
10-
- Analyzes document structure (headings, title)
11-
- Identifies the most changed files
12-
- Provides outputs for use in workflows
9+
- Tracks image modifications with detailed reporting
10+
- Analyzes document structure (headings, titles)
11+
- Identifies the most significantly changed files
12+
- Provides standardized outputs that can be used by any workflow
1313

1414
## Usage
1515

@@ -49,6 +49,7 @@ jobs:
4949
base-ref: 'main'
5050
significant-words-threshold: '100'
5151
skip-if-no-docs: 'true'
52+
debug-mode: 'false'
5253

5354
- name: Create Preview Comment
5455
if: steps.docs-analysis.outputs.docs-changed == 'true'
@@ -74,8 +75,11 @@ jobs:
7475
| `base-ref` | Base reference to compare against | No | `main` |
7576
| `files-changed` | Comma-separated list of files changed (alternative to git diff) | No | `` |
7677
| `max-scan-files` | Maximum number of files to scan | No | `100` |
78+
| `max-files-to-analyze` | Maximum files to analyze in detail (for performance) | No | `20` |
79+
| `throttle-large-repos` | Enable throttling for large repositories | No | `true` |
7780
| `significant-words-threshold` | Threshold for significant text changes | No | `100` |
7881
| `skip-if-no-docs` | Whether to skip if no docs files are changed | No | `true` |
82+
| `debug-mode` | Enable verbose debugging output | No | `false` |
7983

8084
## Outputs
8185

@@ -97,4 +101,58 @@ jobs:
97101
| `most-changed-file` | Path to the most changed file |
98102
| `most-changed-url-path` | URL path for the most changed file |
99103
| `most-significant-image` | Path to the most significant image |
100-
| `doc-structure` | JSON structure of document heading counts |
104+
| `doc-structure` | JSON structure of document heading counts |
105+
| `execution-time` | Execution time in seconds |
106+
| `cache-key` | Cache key for this analysis run |
107+
108+
## Security Features
109+
110+
- Input validation to prevent command injection
111+
- Path sanitization for safer file operations
112+
- Git command retry logic for improved reliability
113+
- Cross-platform compatibility with fallbacks
114+
- Repository size detection with adaptive throttling
115+
- Python integration for safer JSON handling (with bash fallbacks)
116+
117+
## Performance Optimization
118+
119+
- Configurable document scan limits
120+
- Intelligent throttling for large repositories
121+
- Git performance tuning
122+
- Execution time tracking
123+
- Content-based caching
124+
- Debug mode for troubleshooting
125+
126+
## Examples
127+
128+
### Analyzing Documentation Changes for a PR
129+
130+
```yaml
131+
- name: Analyze Documentation Changes
132+
uses: ./.github/actions/docs-analysis
133+
id: docs-analysis
134+
with:
135+
docs-path: 'docs/'
136+
```
137+
138+
### Analyzing Non-Git Files
139+
140+
```yaml
141+
- name: Analyze Documentation Files
142+
uses: ./.github/actions/docs-analysis
143+
id: docs-analysis
144+
with:
145+
files-changed: 'docs/file1.md,docs/file2.md,README.md'
146+
docs-path: 'docs/'
147+
```
148+
149+
### Debug Mode for Troubleshooting
150+
151+
```yaml
152+
- name: Analyze Documentation with Debug Output
153+
uses: ./.github/actions/docs-analysis
154+
id: docs-analysis
155+
with:
156+
docs-path: 'docs/'
157+
debug-mode: 'true'
158+
```

0 commit comments

Comments
 (0)