Skip to content

Commit 98f9e06

Browse files
authored
Update agent-docusarus-dev.yml
1 parent f9768e1 commit 98f9e06

File tree

1 file changed

+73
-182
lines changed

1 file changed

+73
-182
lines changed
Lines changed: 73 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,34 @@
1-
name: Claude Code Documentation Review
1+
name: Docusaurus Project Evaluation
22

33
on:
4-
# Trigger on pull requests to main or dev branch
54
pull_request:
65
branches:
76
- main
87
- dev
98
paths-ignore:
109
- '**.md'
1110
- '**.mdx'
12-
13-
# Trigger on issue comments (for tagging)
14-
issue_comment:
15-
types: [created]
16-
17-
# Trigger on PR review comments
18-
pull_request_review_comment:
19-
types: [created]
2011

2112
jobs:
2213
claude-review:
23-
# Only run if it's a PR or if the comment contains the trigger phrase
24-
if: |
25-
github.event_name == 'pull_request' ||
26-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
27-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude'))
28-
2914
runs-on: ubuntu-latest
3015

3116
permissions:
3217
contents: read
3318
pull-requests: write
34-
issues: write
3519

3620
steps:
3721
- name: Checkout code
3822
uses: actions/checkout@v4
3923
with:
40-
fetch-depth: 0
24+
fetch-depth: 2
4125

4226
- name: Fetch system prompt from private repo
4327
id: fetch-prompt
4428
env:
45-
GH_TOKEN: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN || secrets.GITHUB_TOKEN }}
29+
GH_TOKEN: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }}
4630
run: |
47-
# Fetch the system prompt file from the private repository
48-
echo "Fetching system prompt from netwrix/action-agent-prompts..."
31+
echo "Fetching system prompt..."
4932
5033
RESPONSE=$(curl -s -w "\n%{http_code}" \
5134
-H "Authorization: token $GH_TOKEN" \
@@ -56,199 +39,107 @@ jobs:
5639
CONTENT=$(echo "$RESPONSE" | head -n-1)
5740
5841
if [ "$HTTP_CODE" != "200" ]; then
59-
echo "Failed to fetch system prompt file (HTTP $HTTP_CODE)"
60-
echo "Response: $CONTENT"
42+
echo "Failed to fetch system prompt (HTTP $HTTP_CODE)"
6143
exit 1
6244
fi
6345
64-
# Save the content to a file
6546
echo "$CONTENT" > /tmp/system-prompt.md
66-
67-
# Verify the file was created and has content
68-
if [ ! -s /tmp/system-prompt.md ]; then
69-
echo "System prompt file is empty"
70-
exit 1
71-
fi
72-
7347
echo "System prompt fetched successfully"
74-
echo "File size: $(wc -c < /tmp/system-prompt.md) bytes"
75-
76-
- name: Determine trigger context
77-
id: context
78-
run: |
79-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
80-
echo "is_pr=true" >> $GITHUB_OUTPUT
81-
echo "is_comment=false" >> $GITHUB_OUTPUT
82-
echo "trigger_type=pull_request" >> $GITHUB_OUTPUT
83-
else
84-
echo "is_pr=false" >> $GITHUB_OUTPUT
85-
echo "is_comment=true" >> $GITHUB_OUTPUT
86-
echo "trigger_type=${{ github.event_name }}" >> $GITHUB_OUTPUT
87-
fi
88-
89-
- name: Extract comment prompt (if triggered by comment)
90-
id: extract-prompt
91-
if: steps.context.outputs.is_comment == 'true'
92-
run: |
93-
# Extract the comment after the trigger phrase
94-
COMMENT="${{ github.event.comment.body }}"
95-
# Remove @claude and trim whitespace
96-
PROMPT=$(echo "$COMMENT" | sed 's/@claude//' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
97-
98-
# If prompt is empty after removing trigger, provide a default
99-
if [ -z "$PROMPT" ]; then
100-
PROMPT="Please review the changes in this PR and provide feedback on documentation-related aspects."
101-
fi
102-
103-
echo "comment_prompt<<EOF" >> $GITHUB_OUTPUT
104-
echo "$PROMPT" >> $GITHUB_OUTPUT
105-
echo "EOF" >> $GITHUB_OUTPUT
10648
107-
- name: Check for important file changes
49+
- name: Check for Docusaurus changes
10850
id: check-files
109-
if: steps.context.outputs.is_pr == 'true'
11051
run: |
111-
# Get list of changed files
112-
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD || git diff --name-only HEAD~1)
52+
CHANGED_FILES=$(git diff --name-only HEAD~1)
11353
114-
# Check if docusaurus.config.js or sidebar files were modified
115-
IMPORTANT_FILES=$(echo "$CHANGED_FILES" | grep -E "(docusaurus\.config\.js|.*sidebar.*\.js)" || true)
54+
# Focus on Docusaurus infrastructure files
55+
DOCUSAURUS_FILES=$(echo "$CHANGED_FILES" | grep -E "(docusaurus\.config\.js|sidebars?\.js|babel\.config\.js|package\.json|\.github/|src/)" || true)
11656
117-
# Check for any non-markdown changes
118-
NON_MD_FILES=$(echo "$CHANGED_FILES" | grep -v -E "\.(md|mdx)$" || true)
119-
120-
if [ -n "$IMPORTANT_FILES" ]; then
121-
echo "has_important_changes=true" >> $GITHUB_OUTPUT
122-
echo "### 🎯 Important Documentation Files Changed" >> $GITHUB_STEP_SUMMARY
123-
echo '```' >> $GITHUB_STEP_SUMMARY
124-
echo "$IMPORTANT_FILES" >> $GITHUB_STEP_SUMMARY
125-
echo '```' >> $GITHUB_STEP_SUMMARY
57+
if [ -z "$DOCUSAURUS_FILES" ]; then
58+
echo "No Docusaurus infrastructure files changed. Skipping review."
59+
echo "skip_review=true" >> $GITHUB_OUTPUT
12660
else
127-
echo "has_important_changes=false" >> $GITHUB_OUTPUT
128-
fi
129-
130-
if [ -n "$NON_MD_FILES" ]; then
131-
echo "### 📝 Non-Markdown Files Changed" >> $GITHUB_STEP_SUMMARY
61+
echo "skip_review=false" >> $GITHUB_OUTPUT
62+
echo "### 🎯 Docusaurus Files Changed" >> $GITHUB_STEP_SUMMARY
13263
echo '```' >> $GITHUB_STEP_SUMMARY
133-
echo "$NON_MD_FILES" >> $GITHUB_STEP_SUMMARY
64+
echo "$DOCUSAURUS_FILES" >> $GITHUB_STEP_SUMMARY
13465
echo '```' >> $GITHUB_STEP_SUMMARY
13566
fi
13667
137-
- name: Prepare review prompt
138-
id: prepare-prompt
68+
- name: Create review prompt
69+
if: steps.check-files.outputs.skip_review != 'true'
13970
run: |
140-
if [[ "${{ steps.context.outputs.is_pr }}" == "true" ]]; then
141-
# For PRs, create a comprehensive review prompt
142-
PROMPT="You are reviewing a pull request for a Docusaurus-based documentation site. "
143-
144-
if [[ "${{ steps.check-files.outputs.has_important_changes }}" == "true" ]]; then
145-
PROMPT+="IMPORTANT: This PR includes changes to critical configuration files (docusaurus.config.js and/or sidebar files). Please pay special attention to these changes. "
146-
fi
147-
148-
PROMPT+="Please review the changes and check for:
149-
150-
1. **Configuration Integrity**: Ensure docusaurus.config.js changes are valid and won't break the build
151-
2. **Sidebar Structure**: Verify sidebar configurations are properly formatted and all referenced docs exist
152-
3. **Build Impact**: Identify any changes that might affect the documentation build process
153-
4. **Link Validity**: Check that internal links and references are correct
154-
5. **Best Practices**: Ensure changes follow Docusaurus best practices
155-
6. **Performance**: Flag any changes that might impact site performance
156-
157-
Focus primarily on non-markdown files that affect the documentation infrastructure.
158-
159-
Provide specific, actionable feedback with code suggestions where appropriate."
160-
else
161-
# For comments, use the extracted prompt
162-
PROMPT="${{ steps.extract-prompt.outputs.comment_prompt }}"
163-
fi
164-
165-
# Save prompt to file
166-
echo "$PROMPT" > /tmp/review-prompt.txt
167-
echo "Review prompt prepared successfully"
168-
169-
# Read system prompt for append_system_prompt
170-
SYSTEM_PROMPT=$(cat /tmp/system-prompt.md)
171-
echo "system_prompt<<EOF" >> $GITHUB_OUTPUT
172-
echo "$SYSTEM_PROMPT" >> $GITHUB_OUTPUT
173-
echo "EOF" >> $GITHUB_OUTPUT
71+
cat > /tmp/review-prompt.txt << 'EOF'
72+
Review this pull request focusing exclusively on Docusaurus infrastructure and configuration files.
73+
74+
Analyze changes to:
75+
- docusaurus.config.js (site configuration, plugins, themes)
76+
- sidebars.js (navigation structure)
77+
- package.json (dependencies, scripts)
78+
- Build configuration files
79+
- Source code in src/ directory
80+
- GitHub Actions workflows
81+
82+
For each issue found, provide:
83+
1. Clear explanation of the problem
84+
2. Specific code suggestion with reasoning
85+
3. Potential impact on the documentation site
86+
87+
Ignore all .md and .mdx files - focus only on the technical infrastructure.
88+
EOF
17489
17590
- name: Run Claude Code Review
91+
if: steps.check-files.outputs.skip_review != 'true'
17692
id: claude-review
17793
uses: anthropics/claude-code-base-action@beta
17894
with:
17995
prompt_file: /tmp/review-prompt.txt
180-
append_system_prompt: ${{ steps.prepare-prompt.outputs.system_prompt }}
181-
allowed_tools: "" # Empty string allows all tools
96+
append_system_prompt_file: /tmp/system-prompt.md
97+
allowed_tools: "Read,Grep,Glob,LS"
18298
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
183-
timeout_minutes: "45"
184-
max_turns: "150"
185-
model: "claude-opus-4-20250514"
186-
187-
- name: Generate GitHub App token (for commenting)
188-
id: app-token
189-
if: success() || failure()
190-
uses: actions/create-github-app-token@v2
191-
with:
192-
app-id: ${{ secrets.CLAUDE_APP_ID || vars.CLAUDE_APP_ID }}
193-
private-key: ${{ secrets.CLAUDE_APP_PRIVATE_KEY }}
99+
timeout_minutes: "15"
100+
max_turns: "20"
101+
model: "claude-3-opus-20240229"
194102

195103
- name: Post review summary
196-
if: (success() || failure()) && steps.context.outputs.is_pr == 'true'
104+
if: steps.claude-review.conclusion == 'success'
197105
uses: actions/github-script@v7
198106
with:
199-
github-token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
107+
github-token: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }}
200108
script: |
201109
const fs = require('fs');
202110
const executionFile = '${{ steps.claude-review.outputs.execution_file }}';
203111
204-
let reviewContent = '';
205-
let status = '${{ steps.claude-review.outputs.conclusion }}';
112+
if (!fs.existsSync(executionFile)) {
113+
console.log('No execution file found');
114+
return;
115+
}
206116
207-
if (status === 'success' && fs.existsSync(executionFile)) {
208-
try {
209-
const executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8'));
210-
211-
// Find the last assistant message which should contain the review
212-
for (let i = executionLog.length - 1; i >= 0; i--) {
213-
if (executionLog[i].role === 'assistant' && executionLog[i].content) {
214-
reviewContent = executionLog[i].content;
215-
break;
216-
}
117+
try {
118+
const executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8'));
119+
120+
// Get Claude's final response
121+
let reviewContent = '';
122+
for (let i = executionLog.length - 1; i >= 0; i--) {
123+
if (executionLog[i].role === 'assistant' && executionLog[i].content) {
124+
reviewContent = executionLog[i].content;
125+
break;
217126
}
218-
} catch (error) {
219-
console.error('Error parsing execution log:', error);
220-
reviewContent = 'Error: Could not parse Claude\'s response.';
221127
}
222-
} else if (status === 'failure') {
223-
reviewContent = '⚠️ The review could not be completed. Please check the action logs for details.';
128+
129+
const summary = `## 🤖 Claude Docusaurus Review
130+
131+
${reviewContent}
132+
133+
---
134+
<sub>Automated review by Claude Code</sub>`;
135+
136+
await github.rest.issues.createComment({
137+
issue_number: context.issue.number,
138+
owner: context.repo.owner,
139+
repo: context.repo.repo,
140+
body: summary
141+
});
142+
143+
} catch (error) {
144+
console.error('Error processing review:', error);
224145
}
225-
226-
const summary = `## 🤖 Claude Documentation Review
227-
228-
${reviewContent || 'No review content was generated.'}
229-
230-
---
231-
<sub>Generated by Claude Code Documentation Review Action</sub>`;
232-
233-
await github.rest.issues.createComment({
234-
issue_number: context.issue.number,
235-
owner: context.repo.owner,
236-
repo: context.repo.repo,
237-
body: summary
238-
});
239-
240-
- name: Add workflow summary
241-
if: always()
242-
run: |
243-
echo "## 📊 Claude Review Summary" >> $GITHUB_STEP_SUMMARY
244-
echo "" >> $GITHUB_STEP_SUMMARY
245-
echo "- **Trigger Type**: ${{ steps.context.outputs.trigger_type }}" >> $GITHUB_STEP_SUMMARY
246-
echo "- **Review Status**: ${{ steps.claude-review.outputs.conclusion || 'Not completed' }}" >> $GITHUB_STEP_SUMMARY
247-
echo "- **Important Files Changed**: ${{ steps.check-files.outputs.has_important_changes || 'N/A' }}" >> $GITHUB_STEP_SUMMARY
248-
echo "" >> $GITHUB_STEP_SUMMARY
249-
250-
if [ -f "${{ steps.claude-review.outputs.execution_file }}" ]; then
251-
echo "✅ Review completed. Check the PR comments for Claude's feedback." >> $GITHUB_STEP_SUMMARY
252-
else
253-
echo "❌ Review did not complete successfully." >> $GITHUB_STEP_SUMMARY
254-
fi

0 commit comments

Comments
 (0)