Update agent-docusarus-dev.yml #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Claude Code Documentation Review | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - dev | ||
| paths-ignore: | ||
| - '**.md' | ||
| - '**.mdx' | ||
| jobs: | ||
| claude-review: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 2 | ||
| - name: Fetch system prompt from private repo | ||
| id: fetch-prompt | ||
| env: | ||
| GH_TOKEN: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }} | ||
| run: | | ||
| echo "Fetching system prompt..." | ||
| RESPONSE=$(curl -s -w "\n%{http_code}" \ | ||
| -H "Authorization: token $GH_TOKEN" \ | ||
| -H "Accept: application/vnd.github.v3.raw" \ | ||
| https://api.github.com/repos/netwrix/action-agent-prompts/contents/docs-dev.md?ref=main) | ||
| HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | ||
| CONTENT=$(echo "$RESPONSE" | head -n-1) | ||
| if [ "$HTTP_CODE" != "200" ]; then | ||
| echo "Failed to fetch system prompt (HTTP $HTTP_CODE)" | ||
| exit 1 | ||
| fi | ||
| echo "$CONTENT" > /tmp/system-prompt.md | ||
| echo "System prompt fetched successfully" | ||
| - name: Check for Docusaurus changes | ||
| id: check-files | ||
| run: | | ||
| CHANGED_FILES=$(git diff --name-only HEAD~1) | ||
| DOCUSAURUS_FILES=$(echo "$CHANGED_FILES" | grep -E "(docusaurus\.config\.js|sidebars?\.js|babel\.config\.js|package\.json|\.github/|src/)" || true) | ||
| if [ -z "$DOCUSAURUS_FILES" ]; then | ||
| echo "No Docusaurus infrastructure files changed. Skipping review." | ||
| echo "skip_review=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "skip_review=false" >> $GITHUB_OUTPUT | ||
| echo "### 🎯 Docusaurus Files Changed" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| echo "$DOCUSAURUS_FILES" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| - name: Create review prompt | ||
| if: steps.check-files.outputs.skip_review != 'true' | ||
| run: | | ||
| cat > /tmp/review-prompt.txt << 'EOF' | ||
| Review this pull request focusing exclusively on Docusaurus infrastructure and configuration files. | ||
| Analyze changes to: | ||
| - docusaurus.config.js (site configuration, plugins, themes) | ||
| - sidebars.js (navigation structure) | ||
| - package.json (dependencies, scripts) | ||
| - Build configuration files | ||
| - Source code in src/ directory | ||
| - GitHub Actions workflows | ||
| For each issue found, provide: | ||
| 1. Clear explanation of the problem | ||
| 2. Specific code suggestion with reasoning | ||
| 3. Potential impact on the documentation site | ||
| Ignore all .md and .mdx files - focus only on the technical infrastructure. | ||
| EOF | ||
| - name: Read system prompt for append | ||
| if: steps.check-files.outputs.skip_review != 'true' | ||
| id: read-prompt | ||
| run: | | ||
| SYSTEM_PROMPT=$(cat /tmp/system-prompt.md) | ||
| echo "system_content<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$SYSTEM_PROMPT" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| - name: Run Claude Code Review | ||
| if: steps.check-files.outputs.skip_review != 'true' | ||
| id: claude-review | ||
| uses: anthropics/claude-code-base-action@beta | ||
| with: | ||
| prompt_file: /tmp/review-prompt.txt | ||
| append_system_prompt: ${{ steps.read-prompt.outputs.system_content }} | ||
| allowed_tools: "Read,Grep,Glob,LS" | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| timeout_minutes: "15" | ||
| max_turns: "20" | ||
| model: "claude-sonnet-4-20250514" | ||
| - name: Post review summary | ||
| if: steps.claude-review.conclusion == 'success' | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| EXECUTION_FILE: ${{ steps.claude-review.outputs.execution_file }} | ||
| with: | ||
| github-token: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }} | ||
| script: | | ||
| const fs = require('fs'); | ||
| const executionFile = process.env.EXECUTION_FILE; | ||
| if (!fs.existsSync(executionFile)) { | ||
| console.log('No execution file found'); | ||
| return; | ||
| } | ||
| try { | ||
| const executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8')); | ||
| let reviewContent = ''; | ||
| for (let i = executionLog.length - 1; i >= 0; i--) { | ||
| if (executionLog[i].role === 'assistant' && executionLog[i].content) { | ||
| reviewContent = executionLog[i].content; | ||
| break; | ||
| } | ||
| } | ||
| const summary = "## 🤖 Claude Docusaurus Review\n\n" + | ||
| reviewContent + | ||
| "\n\n---\n<sub>Automated review by Claude Code</sub>"; | ||
| await github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: summary | ||
| }); | ||
| } catch (error) { | ||
| console.error('Error processing review:', error); | ||
| } | ||