Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
87 changes: 87 additions & 0 deletions .github/workflows/autodocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: AutoDocs with Claude

on:
pull_request:

jobs:
autodocs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js 20
uses: actions/setup-node@v3
with:
node-version: "20.x"

# Using a direct prompt
- name: Assess PR for documentation updates
id: autodocs
uses: anthropics/claude-code-base-action@beta
with:
prompt_file: "./.github/workflows/claude-prompt.txt"
model: claude-3-5-haiku-latest
allowed_tools: "Bash(git diff --name-only HEAD~1),Bash(git diff HEAD~1),View,GlobTool,GrepTool,Write"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

- name: Extract and Comment PR Review
if: steps.autodocs.outputs.conclusion == 'success'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const executionFile = '${{ steps.autodocs.outputs.execution_file }}';

// Check if execution file exists
if (!fs.existsSync(executionFile)) {
console.log('❌ Execution file not found:', executionFile);
return;
}

let executionLog;
try {
executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8'));
} catch (error) {
console.log('❌ Failed to parse execution log:', error.message);
return;
}

// Extract the review content from the execution log
// The execution log contains the full conversation including Claude's responses
let review = '';

// Find the last assistant message which should contain the review
for (let i = executionLog.length - 1; i >= 0; i--) {
if (executionLog[i].type === 'assistant' && executionLog[i].message && executionLog[i].message.content) {
// Claude's response structure: message.content[0].text
const content = executionLog[i].message.content;
if (Array.isArray(content) && content.length > 0 && content[0].type === 'text') {
review = content[0].text;
break;
}
}
}

if (review && review.trim()) {
console.log('✅ Found review content, posting comment...');
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "## 🤖 AutoDocs Analysis\n\n" + review + "\n\n*Generated by Claude*"
});
console.log('✅ Comment posted successfully');
} else {
console.log('⚠️ No review content found in execution log');
}

- name: Cleanup execution logs
if: always()
run: |
# Clean up any execution files that might contain sensitive information
if [ -f "${{ steps.autodocs.outputs.execution_file }}" ]; then
rm -f "${{ steps.autodocs.outputs.execution_file }}"
echo "✅ Cleaned up execution file"
fi
13 changes: 13 additions & 0 deletions .github/workflows/claude-prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Consider these factors:
1. Are there new public APIs, functions, or methods?
2. Are there breaking changes to existing functionality?
3. Are there new features or significant behavioral changes?
4. Are there new configuration options or environment variables?
5. Are there changes to installation, setup, or usage procedures?

Write your review as markdown text.
Include:
- Whether documentation updates are needed (and why)
- Your confidence level in this assessment
- Specific areas of documentation that should be updated
- Any recommendations for the developer
28 changes: 28 additions & 0 deletions .github/workflows/claude.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Claude Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude-response:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Optional: add custom trigger phrase (default: @claude)
# trigger_phrase: "/claude"
# Optional: add assignee trigger for issues
# assignee_trigger: "claude"
# Optional: add custom environment variables (YAML format)
# claude_env: |
# NODE_ENV: test
# DEBUG: true
# API_URL: https://api.example.com
Loading