Documentation Regeneration Workflow
Overview
Section titled “Overview”The Documentation Regeneration Workflow (chores-docs-regenerate.yml) automatically regenerates documentation by analyzing the current codebase using AI (OpenCode). This ensures documentation stays in sync with code changes.
Features
Section titled “Features”- 🤖 AI-Powered: Uses OpenCode with Claude, ChatGPT, Gemini, or GitHub Copilot
- 🚀 Auto-Triggered: Runs automatically when code or workflows change
- 🎯 Selective: Only creates PRs when changes are detected
- ✅ Validated: Tests documentation builds before creating PR
- 🔄 Automated: Fully automated with minimal human intervention
- ⚠️ Non-Blocking: Never blocks other workflows - fails gracefully with warnings
Workflow Triggers
Section titled “Workflow Triggers”Automatic on Code Changes
Section titled “Automatic on Code Changes”The workflow automatically triggers when changes are pushed to main branch in:
push: branches: - main paths: - '.github/**' # Workflow or CI/CD changes - 'src/**' # Source code changesWhy these paths?
- **
.github/****: Workflow changes should be reflected in pipeline documentation - **
src/****: Code changes may require API/architecture doc updates
Manual Execution
Section titled “Manual Execution”Run manually from GitHub Actions:
- Go to Actions → Chores — Regenerate Documentation
- Click Run workflow
- Select options:
- AI Provider: Choose from:
anthropic- Anthropic Claude (recommended)openai- OpenAI ChatGPTgoogle- Google Geminigithub- GitHub Copilot
- Create PR: Whether to create a pull request with changes
- AI Provider: Choose from:
Configuration
Section titled “Configuration”Required Secrets
Section titled “Required Secrets”Add at least one of these secrets to your GitHub repository:
ANTHROPIC_API_KEY- For Anthropic Claude (recommended)OPENAI_API_KEY- For OpenAI ChatGPTGOOGLE_API_KEY- For Google GeminiGITHUB_TOKEN- For GitHub Copilot (automatically provided)
Setting Secrets
Section titled “Setting Secrets”- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Add your preferred AI provider’s API key
Note: GITHUB_TOKEN is automatically available in GitHub Actions if you want to use GitHub Copilot.
Permissions
Section titled “Permissions”The workflow requires these permissions:
permissions: contents: write # To create commits pull-requests: write # To create PRsHow It Works
Section titled “How It Works”Workflow Steps
Section titled “Workflow Steps”Trigger Flow
Section titled “Trigger Flow”Documentation Analysis
Section titled “Documentation Analysis”The workflow uses a structured prompt that instructs the AI to:
- Analyze the current codebase
- Update documentation to match implementation
- Preserve existing structure and formatting
- Validate all changes before committing
Files Regenerated
Section titled “Files Regenerated”The workflow focuses on these key documentation files:
| File | Purpose |
|---|---|
index.md | Main landing page and overview |
user-guide.md | User-facing documentation |
api.md | Complete API reference |
architecture.md | System architecture |
development.md | Development guide |
deployment.md | Deployment guide |
pipeline.md | CI/CD pipeline documentation |
Automatic Triggering on Code Changes
Section titled “Automatic Triggering on Code Changes”Zero configuration required! The workflow automatically runs when:
Source Code Changes (src/**)
Section titled “Source Code Changes (src/**)”When you merge changes to source code:
- Workflow analyzes the updated code
- Regenerates relevant documentation (API, architecture)
- Creates PR if documentation needs updating
Example scenarios:
- New functions/classes added → API docs updated
- Architecture changes → Architecture docs updated
- Configuration changes → User guide/deployment docs updated
Workflow Changes (.github/**)
Section titled “Workflow Changes (.github/**)”When you update CI/CD workflows:
- Workflow analyzes the workflow changes
- Regenerates pipeline documentation
- Creates PR with updated workflow docs
Example scenarios:
- New workflow added → Pipeline docs updated
- Workflow steps modified → Setup guides updated
- Secrets changed → Configuration docs updated
Result: Your documentation stays in sync automatically after every code change!
Manual Regeneration
Section titled “Manual Regeneration”Via GitHub Actions
Section titled “Via GitHub Actions”- Go to Actions → Chores — Regenerate Documentation
- Click Run workflow
- Select desired options
- Click Run workflow button
Locally
Section titled “Locally”Use the provided script to regenerate documentation on your machine:
# Ensure you have API key setexport ANTHROPIC_API_KEY="your-key-here"
# Run the regeneration script.github/scripts/regenerate-docs-local.shThe local script:
- Uses the same prompt as the workflow
- Runs OpenCode analysis
- Shows detected changes
- Allows you to review before committing
Reviewing Generated PRs
Section titled “Reviewing Generated PRs”When the workflow detects changes, it creates a PR with:
- Title:
docs: Automated Documentation Regeneration - Label:
documentation,automated - Assignee: The user who triggered the workflow
Review Checklist
Section titled “Review Checklist”When reviewing a documentation PR:
- Verify accuracy of updated content
- Check that code examples are correct
- Ensure links are not broken
- Validate tone and style consistency
- Confirm technical accuracy
- Test documentation site locally
Testing Locally
Section titled “Testing Locally”# Checkout the PR branchgh pr checkout <PR-NUMBER>
# Build and preview docscd docsbun installbun run buildbun run previewCustomization
Section titled “Customization”Modifying the Prompt
Section titled “Modifying the Prompt”Edit the prompt in the workflow file to adjust how documentation is regenerated:
- name: Create documentation regeneration prompt run: | cat > .github/scripts/regenerate-docs-prompt.txt << 'EOF' # Your custom prompt here EOFChanging Default AI Provider
Section titled “Changing Default AI Provider”Edit the workflow to use a different provider by default:
ai_provider: description: 'AI Provider to use' default: 'anthropic' # Options: 'anthropic', 'openai', 'google', 'github'Provider Details:
- anthropic: Uses Claude 3.5 Sonnet (best for comprehensive analysis)
- openai: Uses GPT-4 Turbo (balanced performance)
- google: Uses Gemini 2.0 Flash (fast and efficient)
- github: Uses GitHub Copilot with GPT-4o (integrated with GitHub)
Adjusting Trigger Paths
Section titled “Adjusting Trigger Paths”Modify or add paths to trigger the workflow:
push: branches: - main paths: - '.github/**' - 'src/**' # Add more paths as needed: # - 'package.json' # Trigger on dependency changes # - 'index.ts' # Trigger on main entry point changesTroubleshooting
Section titled “Troubleshooting”Workflow Skipped - No AI Provider
Section titled “Workflow Skipped - No AI Provider”Symptom: Workflow completes with warning “No AI provider available”
Cause: No API keys found in repository secrets
Solution:
-
Add at least one API key to repository secrets:
ANTHROPIC_API_KEY(for Claude)OPENAI_API_KEY(for ChatGPT)GOOGLE_API_KEY(for Gemini)GITHUB_TOKEN(usually auto-available for Copilot)
-
Re-run the workflow or wait for next trigger
Note: This is a warning, not an error. The workflow will not block other workflows from running.
No Changes Detected
Section titled “No Changes Detected”Symptom: Workflow completes but reports no changes
Possible Causes:
- Documentation is already up-to-date
- OpenCode didn’t find any discrepancies
- AI provider rate limits
Solution:
- Review workflow logs for OpenCode output
- Check if API key is valid and has quota
- Try running locally with verbose output
Build Failure
Section titled “Build Failure”Symptom: Documentation build fails in validation step
Possible Causes:
- Invalid markdown syntax
- Broken frontmatter
- Missing required files
Solution:
- Check workflow logs for specific error
- Test build locally:
cd docs && bun run build - Fix syntax errors and re-run workflow
PR Not Created
Section titled “PR Not Created”Symptom: Workflow completes but no PR appears
Possible Causes:
- No changes detected
- Missing permissions
create_prinput set to false
Solution:
- Verify
has_changesoutput in workflow logs - Check workflow has
pull-requests: writepermission - Ensure
create_pris not disabled
API Rate Limits
Section titled “API Rate Limits”Symptom: Workflow fails with rate limit errors
Possible Causes:
- Too many API requests in short time
- Exceeded daily/monthly quota
Solution:
- Wait for rate limit to reset
- Consider upgrading API plan
- Temporarily disable auto-trigger by removing paths from workflow
- Use manual trigger only when needed
Non-Blocking Behavior
Section titled “Non-Blocking Behavior”This workflow is designed to never block other workflows from running:
Graceful Failure
Section titled “Graceful Failure”- ✅ Uses
continue-on-error: trueat the job level - ✅ All steps check for provider availability before executing
- ✅ Missing API keys result in warnings, not errors
- ✅ Workflow summary shows clear status and action items
Fallback Strategy
Section titled “Fallback Strategy”If the requested provider isn’t available, the workflow:
- Shows a warning about the missing provider
- Lists available providers
- Falls back to the first available provider
- Continues with documentation regeneration
When Provider is Unavailable
Section titled “When Provider is Unavailable”If no providers are available:
- Workflow logs a clear warning message
- Step summary shows required action items
- Workflow completes successfully (exit code 0)
- Other workflows continue unaffected
Example warning message:
⚠️ WARNING: No AI provider API keys found Please add at least one of: - ANTHROPIC_API_KEY (for Claude) - OPENAI_API_KEY (for ChatGPT) - GOOGLE_API_KEY (for Gemini) - GITHUB_TOKEN (for Copilot)
Skipping documentation regeneration...Best Practices
Section titled “Best Practices”1. Regular Reviews
Section titled “1. Regular Reviews”Even with automated regeneration, periodically review documentation manually to ensure:
- Tone and voice remain consistent
- Examples are relevant and helpful
- No AI hallucinations or inaccuracies
2. Incremental Updates
Section titled “2. Incremental Updates”After major code changes:
- Run workflow manually
- Review generated PR carefully
- Make manual adjustments if needed
3. Version Documentation
Section titled “3. Version Documentation”When releasing new versions:
- Trigger documentation regeneration
- Review for version-specific changes
- Ensure migration guides are updated
4. Monitor Costs
Section titled “4. Monitor Costs”Track AI API usage:
- Set up billing alerts
- Monitor token consumption
- Adjust frequency if costs are high
Integration with Other Workflows
Section titled “Integration with Other Workflows”The documentation regeneration workflow integrates with:
Deploy Documentation Workflow
Section titled “Deploy Documentation Workflow”After a regeneration PR is merged:
- Changes trigger
deploy-docs.yml - Documentation is built
- Deployed to
docsbranch - Published to GitHub Pages
Version Update Workflow
Section titled “Version Update Workflow”Documentation regeneration can be triggered after version updates to ensure version numbers are current.
Monitoring
Section titled “Monitoring”Success Metrics
Section titled “Success Metrics”Track these metrics to measure effectiveness:
- PR Creation Rate: How often changes are detected
- Review Time: How long PRs take to review
- Merge Rate: Percentage of PRs merged without changes
- Build Success: Documentation build success rate
Logs and Debugging
Section titled “Logs and Debugging”View detailed logs:
- Go to Actions → Chores — Regenerate Documentation
- Click on a workflow run
- Expand steps to see detailed output
Future Enhancements
Section titled “Future Enhancements”Potential improvements:
- Add support for more AI providers
- Implement smart diffing to show only significant changes
- Add automatic review approval for minor changes
- Integrate with documentation quality checks
- Add support for multi-language documentation
Related Documentation
Section titled “Related Documentation”Support
Section titled “Support”For issues with documentation regeneration:
- Check workflow logs
- Review this troubleshooting guide
- Open an issue with
documentationlabel - Include workflow run link and error messages
Version History
Section titled “Version History”- v1.0.0 (2025-01-14): Initial documentation regeneration workflow