Skip to content

CodeBoarding Documentation update workflow #4

CodeBoarding Documentation update workflow

CodeBoarding Documentation update workflow #4

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: '.codeboarding'
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 || '.codeboarding' }}
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
# Append generated MDX files to development.mdx
- name: Append generated docs to development.mdx
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
run: |
# Check if the output directory exists and has .mdx files
if [ -d "${{ steps.codeboarding.outputs.output_directory }}" ]; then
# Add a section header for auto-generated documentation
echo "" >> docs/development.mdx
echo "## Auto-Generated API Documentation" >> docs/development.mdx
echo "" >> docs/development.mdx
echo "The following documentation was automatically generated from the codebase:" >> docs/development.mdx
echo "" >> docs/development.mdx
# Find all .mdx files in the output directory and append their content
find "${{ steps.codeboarding.outputs.output_directory }}" -name "*.mdx" -type f | sort | while read file; do
if [ -f "$file" ]; then
filename=$(basename "$file" .mdx)
# Add a header for each file
echo "### $(echo "$filename" | sed 's/_/ /g' | sed 's/\b\w/\U&/g')" >> docs/development.mdx
echo "" >> docs/development.mdx
# Append the content of the file (skip frontmatter if present)
if head -n 1 "$file" | grep -q "^---"; then
# Skip frontmatter (from first --- to second ---)
sed -n '/^---$/,/^---$/d; /^---$/,$p' "$file" >> docs/development.mdx
else
# No frontmatter, append entire file
cat "$file" >> docs/development.mdx
fi
echo "" >> docs/development.mdx
echo "---" >> docs/development.mdx
echo "" >> docs/development.mdx
fi
done
fi
- name: Commit and push changes
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "docs: update codeboarding documentation
## 📚 Documentation Update
This commit 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 appended to the development documentation.
🤖 This commit was automatically generated by the CodeBoarding documentation update workflow."
git push