Skip to content

Sync Documentation from SharpMUSH #56

Sync Documentation from SharpMUSH

Sync Documentation from SharpMUSH #56

name: Sync Documentation from SharpMUSH
on:
schedule:
# Run daily at 6 AM UTC
- cron: '0 6 * * *'
workflow_dispatch:
# Allow manual triggering
push:
branches:
- main
paths:
- '.github/workflows/sync-documentation.yml'
jobs:
sync-docs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Clone SharpMUSH repository
run: |
git clone https://github.com/SharpMUSH/SharpMUSH.git temp-sharpmush
- name: Check if documentation exists
id: check_docs
run: |
if [ -d "temp-sharpmush/SharpMUSH.Documentation/Helpfiles/SharpMUSH" ]; then
echo "docs_exist=true" >> $GITHUB_OUTPUT
echo "Documentation folder found"
else
echo "docs_exist=false" >> $GITHUB_OUTPUT
echo "Documentation folder not found"
fi
- name: Make scripts executable
if: steps.check_docs.outputs.docs_exist == 'true'
run: |
chmod +x .github/scripts/*.sh
- name: Process and organize documentation
if: steps.check_docs.outputs.docs_exist == 'true'
run: |
# Run the modular processing script
./.github/scripts/process_documentation.sh "temp-sharpmush/SharpMUSH.Documentation/Helpfiles/SharpMUSH" "temp-processed"
id: process_docs
- name: Update documentation folders
if: steps.check_docs.outputs.docs_exist == 'true'
run: |
# Run the update script
./.github/scripts/update_documentation_folders.sh temp-processed
- name: Clean up temporary files
run: |
rm -rf temp-sharpmush temp-processed
- name: Check for changes
id: check_changes
run: |
git add -A
if git diff --cached --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected"
git diff --cached --name-only
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
run: |
# Create commit message with details
COMMIT_MSG="docs: sync documentation from SharpMUSH/SharpMUSH"
if [ "${{ steps.process_docs.outputs.function_count }}" != "" ]; then
COMMIT_MSG="$COMMIT_MSG
Updated documentation:
- Functions: ${{ steps.process_docs.outputs.function_count }} files
- Commands: ${{ steps.process_docs.outputs.command_count }} files
- Configuration: ${{ steps.process_docs.outputs.config_count }} files
Source: SharpMUSH/SharpMUSH repository
Date: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
fi
git commit -m "$COMMIT_MSG"
git push origin main
- name: Create summary
run: |
echo "## Documentation Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check_docs.outputs.docs_exist }}" == "false" ]; then
echo "❌ **Documentation folder not found** in SharpMUSH/SharpMUSH repository" >> $GITHUB_STEP_SUMMARY
echo "Expected path: \`SharpMUSH.Documentation/Helpfiles/SharpMUSH\`" >> $GITHUB_STEP_SUMMARY
elif [ "${{ steps.check_changes.outputs.changes }}" == "false" ]; then
echo "✅ **No changes detected** - documentation is up to date" >> $GITHUB_STEP_SUMMARY
else
echo "✅ **Documentation successfully synced**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Updated Files:" >> $GITHUB_STEP_SUMMARY
echo "- **Functions**: ${{ steps.process_docs.outputs.function_count }} files" >> $GITHUB_STEP_SUMMARY
echo "- **Commands**: ${{ steps.process_docs.outputs.command_count }} files" >> $GITHUB_STEP_SUMMARY
echo "- **Configuration**: ${{ steps.process_docs.outputs.config_count }} files" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📅 **Sync Date**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
fi