A powerful GitHub Action that leverages AI to automatically generate professional Markdown documentation from YAML files. Perfect for API documentation, schema documentation, and configuration guides.
- π€ AI-Powered Generation: Uses OpenAI's GPT models for intelligent content creation
- π Template-Based: Handlebars-style templates ensure consistent formatting
- π Iterative Refinement: Multi-pass generation with quality scoring
- π Quality Control: Configurable completeness thresholds and validation
- π GitHub Actions Ready: Both composite action and reusable workflow support
- π Batch Processing: Handle multiple YAML files simultaneously
- π― Smart Change Detection: Only process changed YAML files for efficiency
- π Automatic PR Creation: Built-in pull request creation with generated docs
- π§ Smart PR Titles: AI-generated descriptive titles based on content changes
- βοΈ Highly Configurable: Customize models, iterations, and output paths
name: Generate API Documentation
on:
push:
paths:
- 'yaml/**/*.yaml'
- 'yaml/**/*.yml'
pull_request:
paths:
- 'yaml/**/*.yaml'
- 'yaml/**/*.yml'
jobs:
generate_docs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for change detection
- name: Generate API Documentation
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './yaml'
output_path: './docs'
process_changed_only: 'true' # Only process changed files
create_pull_request: 'true' # Auto-create PR with results
name: Generate Documentation
on: [push]
jobs:
generate_docs:
uses: DomoApps/documentation-generator-action/.github/workflows/action.yml@main
with:
yaml_input_path: './api-specs'
output_path: './docs'
openai_model: 'gpt-4o'
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- OpenAI API Key: Add
OPENAI_API_KEY
to your repository secrets - YAML Files: Place your YAML/YML files in the designated input directory
- GitHub Actions: Ensure Actions are enabled in your repository
- Repository Access: Ensure your repository has access to the
DomoApps
organization
- Case Sensitive: Use exact case
DomoApps/documentation-generator-action
(notdomoapps
) - Branch Reference: Use
@main
branch for latest version
Input | Description | Default | Required |
---|---|---|---|
openai_api_key |
OpenAI API key for AI processing | β | |
yaml_input_path |
Path to directory containing YAML files | ./yaml |
|
output_path |
Output directory for generated documentation | ./docs |
|
template_path |
Custom template file path | default |
|
openai_model |
AI model to use | gpt-4o |
|
max_iterations |
Maximum refinement iterations | 10 |
|
completeness_threshold |
Quality score threshold (0-100) | 90 |
|
timeout_minutes |
Maximum processing time | 30 |
|
process_changed_only |
Only process changed YAML files | false |
|
base_ref |
Base reference for change detection | main |
|
create_pull_request |
Create PR with generated documentation | false |
|
pr_title |
Title for the pull request | π Update API Documentation |
|
pr_branch_name |
Name for the PR branch | docs/update-api-docs |
The action now includes built-in change detection that automatically identifies which YAML files have been modified:
- name: Generate API Documentation
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './yaml'
output_path: './docs'
process_changed_only: 'true' # π― Only process changed files
Benefits:
- β‘ Faster Processing: Only regenerates docs for changed files
- π° Cost Effective: Reduces OpenAI API calls
- π Efficient CI/CD: Shorter pipeline execution times
Requirements:
- Set
fetch-depth: 0
in checkout action for git history - Works with push events, pull requests, and manual triggers
Generate documentation and automatically create pull requests:
- name: Generate API Documentation
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './yaml'
output_path: './docs'
create_pull_request: 'true' # π Auto-create PR
pr_title: 'π Updated API Documentation' # Fallback title
pr_branch_name: 'docs/api-update'
When process_changed_only: "true"
is enabled, the action automatically generates intelligent PR titles based on the actual content changes:
Examples of AI-generated titles:
π Add FileSet management endpoints
π Update AI text summarization API
β¨ New user authentication methods
π Fix payment processing parameters
Benefits:
- Context-Aware: Understands what actually changed in your APIs
- Professional: Uses consistent emoji and formatting conventions
- Concise: Stays under 60 characters for clean PR lists
- Fallback Safe: Uses your custom
pr_title
if AI generation fails
Create your own Handlebars template for customized output:
- uses: your-org/yaml-to-docs-action@v1
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './openapi'
output_path: './api-docs'
- uses: your-org/yaml-to-docs-action@v1
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './specs'
output_path: './documentation'
openai_model: 'gpt-4'
max_iterations: '15'
completeness_threshold: '95'
template_path: './custom-template.md'
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Documentation
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
- name: Commit Documentation
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add docs/
git diff --staged --quiet || git commit -m "π Update generated documentation"
git push
The action follows an iterative refinement process:
- YAML Analysis: Parses YAML files and extracts structure, data types, and relationships
- Template Population: Maps YAML data to template placeholders using AI
- Documentation Generation: Creates initial Markdown documentation
- Quality Validation: Scores documentation on completeness, accuracy, and clarity
- Refinement Loop: Iteratively improves documentation until exit conditions are met
The process completes when:
- Overall quality score β₯ completeness threshold (default: 90%)
- All template placeholders are filled
- No critical documentation gaps remain
- Maximum iterations reached (default: 10)
The action uses Handlebars-style templates with placeholders like:
{{API_NAME}}
- API title{{HTTP_METHOD}}
- Request method{{#each PARAMETERS}}
- Parameter loops{{#if CONDITION}}
- Conditional sections
See templates/product-api.template.md
for the complete template structure.
Generated documentation files are saved as GitHub artifacts and can be downloaded from the Actions tab.
- Create a new repository (recommended name:
documentation-generator-action
) - Copy this codebase to your new repository
- Update references to point to your organization/repository
- Create your first release with proper versioning
# Create and push your first release
git tag -a v1.0.0 -m "Release v1.0.0: Initial stable release"
git push origin v1.0.0
# Create major version tag for easy consumption
git tag -a v1 -m "Latest v1.x.x release"
git push origin v1
DomoApps/documentation-generator-action/
βββ .github/workflows/action.yml # Reusable workflow
βββ action.yml # Composite action
βββ src/ # Core Python code
βββ samples/ # Example files
βββ tests/ # Test suite
βββ README.md # This documentation
βββ CHANGELOG.md # Version history
βββ RELEASES.md # Release process
# Set environment variables
export OPENAI_API_KEY="your-api-key"
export YAML_INPUT_PATH="./samples"
export MARKDOWN_OUTPUT_PATH="./output"
export TEMPLATE_PATH="./templates/product-api.template.md"
# Run the generator
python src/doc_generator_main.py
- Input:
samples/filesets.yaml
- Comprehensive API specification - Template:
templates/product-api.template.md
- Professional API documentation template - Expected Output: Rich markdown with tables, code examples, and structured sections
# In your API spec repository
name: Generate API Docs
on: [push]
jobs:
docs:
uses: DomoApps/documentation-generator-action/.github/workflows/action.yml@main
with:
yaml_input_path: './specs'
output_path: './docs'
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Generate docs for multiple services
name: Generate All Documentation
on: [push]
jobs:
user-service-docs:
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './services/user-api'
output_path: './docs/user-service'
payment-service-docs:
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './services/payment-api'
output_path: './docs/payment-service'
# Generate docs and deploy to GitHub Pages
name: Update Documentation Site
on: [push]
jobs:
generate-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate API Documentation
uses: DomoApps/documentation-generator-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
yaml_input_path: './api-specs'
output_path: './docs-site/content/api'
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs-site
Issue | Solution |
---|---|
Unable to resolve action |
Ensure exact case: DomoApps/documentation-generator-action@main |
Permission denied |
Verify repository access to DomoApps organization |
OPENAI_API_KEY not found |
Add API key to repository secrets |
No YAML files found |
Check yaml_input_path points to directory with .yaml/.yml files |
Template not found |
Use template_path: 'default' or provide valid custom template path |
- Check Action Logs: View detailed logs in GitHub Actions tab
- Verify Inputs: Ensure all required inputs are provided
- Test Locally: Use the local testing commands from the repository
- Check Permissions: Verify workflow has necessary permissions
Contributions are welcome! Please follow these steps:
- Create a branch
<your name>/<feature or bug>
from themain
branch to ensure your changes are based on the latest code. - Make your changes, ensuring they align with the project's coding standards and guidelines.
- Write clear and concise commit messages to describe your changes.
- Test your changes thoroughly to ensure they work as expected and do not introduce any new issues.
- Submit a pull request with a clear and detailed description of your changes, including the problem being solved, the approach taken, and any potential impacts.
- Engage in the review process by addressing feedback and making necessary updates to your pull request.