Skip to content

Added docs-update.yml #1

Added docs-update.yml

Added docs-update.yml #1

Workflow file for this run

name: CodeBoarding Documentation update workflow
on:
workflow_dispatch:
inputs:
repository_url:
description: 'Repository URL to test with'
required: false
default: 'https://github.com/CodeBoarding/mcp-use'
type: string
source_branch:
description: 'Source branch for generation'
required: false
default: 'main'
type: string
target_branch:
description: 'Target branch for pull request'
required: false
default: 'main'
type: string
output_format:
description: 'Output format for documentation'
required: false
default: '.mdx'
type: choice
options:
- '.mdx'
- '.md'
- '.rst'
output_directory:
description: 'Output directory for documentation files'
required: false
default: 'docs/api-reference/auto-generated'
type: string
jobs:
update-docs-action-usage:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Required to access branch history
# Determine branches based on context
- name: Set branch variables
id: set-branches
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "source_branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
echo "target_branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event.inputs.source_branch }}" != "" ] && [ "${{ github.event.inputs.target_branch }}" != "" ]; then
echo "source_branch=${{ github.event.inputs.source_branch }}" >> $GITHUB_OUTPUT
echo "target_branch=${{ github.event.inputs.target_branch }}" >> $GITHUB_OUTPUT
else
echo "source_branch=main" >> $GITHUB_OUTPUT
echo "target_branch=main" >> $GITHUB_OUTPUT
fi
- name: Fetch CodeBoarding Documentation
timeout-minutes: 30
id: codeboarding
uses: CodeBoarding/[email protected]
with:
repository_url: ${{ github.event.inputs.repository_url }}
source_branch: ${{ steps.set-branches.outputs.source_branch }}
target_branch: ${{ steps.set-branches.outputs.target_branch }}
output_directory: ${{ github.event.inputs.output_directory || 'docs/api-reference/auto-generated' }}
output_format: ${{ github.event.inputs.output_format || '.mdx' }}
- name: Display Action Results
run: |
echo "Documentation files created: ${{ steps.codeboarding.outputs.markdown_files_created }}"
echo "JSON files created: ${{ steps.codeboarding.outputs.json_files_created }}"
echo "Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}"
echo "JSON directory: ${{ steps.codeboarding.outputs.json_directory }}"
echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}"
# Check if we have any changes to commit
- name: Check for changes
id: git-changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "has_git_changes=true" >> $GITHUB_OUTPUT
else
echo "has_git_changes=false" >> $GITHUB_OUTPUT
fi
# Update documentation to include the generated files
- name: Update documentation structure with generated docs
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
run: |
# Install jq for JSON manipulation
sudo apt-get update && sudo apt-get install -y jq
# Update docs.json to include auto-generated files in API Reference
if [ -d "${{ steps.codeboarding.outputs.output_directory }}" ]; then
# Create a list of generated files for docs.json
generated_files=""
find "${{ steps.codeboarding.outputs.output_directory }}" -name "*.mdx" -type f | while read file; do
# Get relative path from docs root without extension
rel_path=$(echo "$file" | sed 's|^docs/||' | sed 's|\.mdx$||')
if [ -z "$generated_files" ]; then
generated_files="\"$rel_path\""
else
generated_files="$generated_files,\"$rel_path\""
fi
echo "$rel_path" >> generated_files_list.txt
done
# Update docs.json to include auto-generated files
if [ -s generated_files_list.txt ]; then
# Create a new group for auto-generated docs
temp_json=$(mktemp)
jq --argjson new_group '{
"group": "Auto-Generated API Documentation",
"pages": []
}' '
.navigation[0].groups |= map(
if .group == "API Reference" then
.groups += [$new_group] |
.groups[-1].pages = (input | split("\n") | map(select(length > 0)))
else . end
)' docs/docs.json generated_files_list.txt > "$temp_json"
# If the above doesn't work, try a simpler approach
if [ $? -ne 0 ]; then
# Simple insertion: add auto-generated files to existing API Reference group
while read -r file_path; do
if [ -n "$file_path" ]; then
jq --arg path "$file_path" '
(.navigation[] | select(.tab == "API Reference") | .groups[] | select(.group == "API Reference") | .pages) += [$path]
' docs/docs.json > "$temp_json" && mv "$temp_json" docs/docs.json
fi
done < generated_files_list.txt
else
mv "$temp_json" docs/docs.json
fi
rm -f generated_files_list.txt
fi
# Update development.mdx to mention auto-generated documentation
# Insert before the Project Structure section
sed -i '/## Project Structure/i \
## Auto-Generated API Documentation\
\

Check failure on line 152 in .github/workflows/docs-update.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docs-update.yml

Invalid workflow file

You have an error in your yaml syntax on line 152
This project includes automatically generated API documentation files created by the CodeBoarding documentation workflow. These files provide detailed documentation for the codebase and are updated automatically when changes are made to the source code.\
\
The auto-generated documentation files are located in the **API Reference** section of this documentation site under "Auto-Generated API Documentation".\
\
' docs/development.mdx
fi
- name: Create Pull Request
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT_TOKEN }}
commit-message: "docs: update codeboarding documentation"
title: "📚 CodeBoarding Documentation Update"
body: |
## 📚 Documentation Update
This PR contains updated documentation files fetched from the CodeBoarding service.
### 📊 Summary
- **Documentation files created/updated**: ${{ steps.codeboarding.outputs.markdown_files_created }}
- **JSON files created/updated**: ${{ steps.codeboarding.outputs.json_files_created }}
- **Documentation directory**: `${{ steps.codeboarding.outputs.output_directory }}/`
- **JSON directory**: `${{ steps.codeboarding.outputs.json_directory }}/`
- **Output format**: `${{ github.event.inputs.output_format || '.mdx' }}`
- **Repository analyzed**: `${{ steps.codeboarding.outputs.repo_url }}`
The generated .mdx files have been automatically integrated into the development documentation.
🤖 This PR was automatically generated by the CodeBoarding documentation update workflow.
branch: docs/codeboarding-update
base: main
delete-branch: true