From 96e718d06cb7539cc59db57199a29ff9eceec995 Mon Sep 17 00:00:00 2001 From: yuri <8012032+yurisasuke@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:12:51 +0300 Subject: [PATCH 1/4] Update deploy-docs.yml --- .github/workflows/deploy-docs.yml | 141 +++++++++++++----------------- 1 file changed, 63 insertions(+), 78 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index be7c04bec..e8b3e0065 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -4,9 +4,9 @@ on: workflow_dispatch: inputs: subfolder: - description: 'Subfolder for documentation (e.g., docs3, docsv3, docs)' + description: 'Subfolder for documentation (e.g., docs3, docsv3, docs). Leave empty for root deployment.' required: false - default: 'docs3' + default: '' type: string # Ensure only latest deployment runs @@ -46,86 +46,56 @@ jobs: echo "โœ… Found branches-config.json" cat branches-config.json - - name: Cleanup old version folders and assets + - name: Cleanup everything except preserved files run: | - echo "๐Ÿงน Cleaning up old version folders and assets..." - - # Get current version folders from config - current_folders=$(python3 -c "import json; config=json.load(open('branches-config.json')); folders=[v.get('folder','') for v in config.get('versions',[]) if v.get('folder','')]; print(' '.join(folders))") - - echo "๐Ÿ“‹ Current version folders: $current_folders" - - # Define asset types that will be regenerated - asset_types=( - "style.css" - "images" - "img" - "logo" - "favicon.ico" - "favicon.png" - "snippets" + echo "๐Ÿงน Cleaning up everything except preserved files..." + + # Define files/folders to preserve during cleanup + preserve_items=( + ".gitignore" + ".vale.ini" + "branches-config.json" + "README.md" + ".github" + ".devcontainer" + ".vale" + "scripts" + ".git" ) - # Remove old assets (they'll be regenerated from current versions) - echo "๐ŸŽจ Cleaning up old assets..." - for asset in "${asset_types[@]}"; do - if [ -e "$asset" ]; then - echo "๐Ÿ—‘๏ธ Removing old asset: $asset" - rm -rf "$asset" + echo "๐Ÿ“‹ Files/folders to preserve:" + printf '%s\n' "${preserve_items[@]}" + + # Create temporary backup of preserved items + echo "๐Ÿ’พ Creating temporary backup of preserved items..." + mkdir -p .temp_backup + for item in "${preserve_items[@]}"; do + if [ -e "$item" ]; then + echo " ๐Ÿ“ฆ Backing up: $item" + cp -r "$item" .temp_backup/ fi done - # Remove old docs.json (will be regenerated) - if [ -f "docs.json" ]; then - echo "๐Ÿ—‘๏ธ Removing old docs.json" - rm -f "docs.json" - fi - - # Also clean up the subfolder if it exists (using input parameter) - SUBFOLDER="${{ inputs.subfolder || 'docs3' }}" - if [ -n "$SUBFOLDER" ] && [ -d "$SUBFOLDER" ]; then - echo "๐Ÿ—‘๏ธ Removing old $SUBFOLDER subfolder" - rm -rf "$SUBFOLDER" - fi - - # Remove old version folders that aren't in the current config - # Look for directories that look like version folders (numeric or version-like names) - for dir in */; do - if [ -d "$dir" ]; then - dir_name=${dir%/} # Remove trailing slash - - # Skip non-version directories - if [[ "$dir_name" =~ ^\..*$ ]] || [ "$dir_name" = ".github" ]; then - continue + # Clean everything (files and directories) + echo "๐Ÿ—‘๏ธ Removing all content except preserved items..." + find . -mindepth 1 -maxdepth 1 ! -name '.temp_backup' -exec rm -rf {} + + + # Restore preserved items + echo "โ™ป๏ธ Restoring preserved items..." + if [ -d ".temp_backup" ]; then + for item in .temp_backup/*; do + if [ -e "$item" ]; then + item_name=$(basename "$item") + echo " ๐Ÿ“ฆ Restoring: $item_name" + cp -r "$item" . fi - - # Check if this folder is in current config - is_current=false - for current in $current_folders; do - if [ "$dir_name" = "$current" ]; then - is_current=true - break - fi - done - - # If it's not in current config and looks like a version folder, remove it - if [ "$is_current" = false ]; then - # Only remove if it looks like a version folder (contains numbers/dots or common version patterns) - if [[ "$dir_name" =~ ^[0-9]+\.[0-9]+$ ]] || [[ "$dir_name" =~ ^v[0-9] ]] || [[ "$dir_name" =~ ^[0-9] ]]; then - echo "๐Ÿ—‘๏ธ Removing old version folder: $dir_name" - rm -rf "$dir" - else - echo "๐Ÿ“ Keeping non-version directory: $dir_name" - fi - else - echo "๐Ÿ“ Keeping current version folder: $dir_name (will be refreshed)" - fi - fi - done + done + rm -rf .temp_backup + fi echo "โœ… Cleanup completed!" echo "๐Ÿ“ Remaining files after cleanup:" - ls -la | grep -E "^[d-]" | head -10 + ls -la | head -10 - name: Clone and organize branches run: | @@ -194,18 +164,33 @@ jobs: run: | echo "๐Ÿ”„ Running documentation merger..." - # Get subfolder from input (with fallback) - SUBFOLDER="${{ inputs.subfolder || 'docs3' }}" - echo "๐Ÿ“ Using subfolder: $SUBFOLDER" + # Handle subfolder parameter properly + # Distinguish between: no parameter, empty string, and specific value + if [ -z "${{ github.event.inputs.subfolder }}" ]; then + # No parameter provided - merge to root (no subfolder) + USE_SUBFOLDER=false + echo "๐Ÿ“ No subfolder parameter provided - merging to root" + elif [ "${{ github.event.inputs.subfolder }}" = "" ]; then + # Empty string provided - merge to root (no subfolder) + USE_SUBFOLDER=false + echo "๐Ÿ“ Empty subfolder parameter provided - merging to root" + else + # Specific folder provided - use it + SUBFOLDER="${{ github.event.inputs.subfolder }}" + USE_SUBFOLDER=true + echo "๐Ÿ“ Using subfolder: $SUBFOLDER" + fi - # Run the merge script with branches config - if [ -n "$SUBFOLDER" ]; then + # Run the merge script with or without subfolder parameter + if [ "$USE_SUBFOLDER" = true ]; then + echo "๐Ÿ”ง Running merge with subfolder: $SUBFOLDER" python3 scripts/merge_docs_configs.py \ --branches-config branches-config.json \ --base-dir . \ --subfolder "$SUBFOLDER" \ --output docs.json else + echo "๐Ÿ”ง Running merge to root (no subfolder parameter passed)" python3 scripts/merge_docs_configs.py \ --branches-config branches-config.json \ --base-dir . \ @@ -275,7 +260,7 @@ jobs: - โœ… Cleaned up outdated version folders ### Subfolder Used: - `${{ inputs.subfolder || 'docs3' }}` + `${{ github.event.inputs.subfolder || 'root (no subfolder)' }}` --- From 8d09e83f4d774891fb2a73843e4f5d542e1aa0f3 Mon Sep 17 00:00:00 2001 From: yuri <8012032+yurisasuke@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:16:33 +0300 Subject: [PATCH 2/4] Update trigger-docs-deploy.yml --- .github/workflows/trigger-docs-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-docs-deploy.yml b/.github/workflows/trigger-docs-deploy.yml index fac486e0d..bff2b7b68 100644 --- a/.github/workflows/trigger-docs-deploy.yml +++ b/.github/workflows/trigger-docs-deploy.yml @@ -16,4 +16,4 @@ jobs: -H "Authorization: token ${{ secrets.ORG_GH_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/${{ github.repository }}/actions/workflows/deploy-docs.yml/dispatches \ - -d '{"ref": "production", "inputs": {"subfolder": "docs3"}}' + -d '{"ref": "production", "inputs": {"subfolder": ""}}' From 1e6488c7083bf60477488007930394631c62f9cd Mon Sep 17 00:00:00 2001 From: yuri <8012032+yurisasuke@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:29:22 +0300 Subject: [PATCH 3/4] Update deploy-docs.yml --- .github/workflows/deploy-docs.yml | 58 ++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index e8b3e0065..3eeae97a8 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -66,32 +66,48 @@ jobs: echo "๐Ÿ“‹ Files/folders to preserve:" printf '%s\n' "${preserve_items[@]}" - # Create temporary backup of preserved items - echo "๐Ÿ’พ Creating temporary backup of preserved items..." - mkdir -p .temp_backup - for item in "${preserve_items[@]}"; do + # Clean everything (files and directories) except preserved items + echo "๐Ÿ—‘๏ธ Removing all content except preserved items..." + for item in *; do if [ -e "$item" ]; then - echo " ๐Ÿ“ฆ Backing up: $item" - cp -r "$item" .temp_backup/ + # Check if this item should be preserved + should_preserve=false + for preserve_item in "${preserve_items[@]}"; do + if [ "$item" = "$preserve_item" ]; then + should_preserve=true + break + fi + done + + if [ "$should_preserve" = false ]; then + echo " ๐Ÿ—‘๏ธ Removing: $item" + rm -rf "$item" + else + echo " ๐Ÿ“ Preserving: $item" + fi fi done - # Clean everything (files and directories) - echo "๐Ÿ—‘๏ธ Removing all content except preserved items..." - find . -mindepth 1 -maxdepth 1 ! -name '.temp_backup' -exec rm -rf {} + - - # Restore preserved items - echo "โ™ป๏ธ Restoring preserved items..." - if [ -d ".temp_backup" ]; then - for item in .temp_backup/*; do - if [ -e "$item" ]; then - item_name=$(basename "$item") - echo " ๐Ÿ“ฆ Restoring: $item_name" - cp -r "$item" . + # Also clean hidden files/directories (except preserved ones) + for item in .[^.]*; do + if [ -e "$item" ]; then + # Check if this item should be preserved + should_preserve=false + for preserve_item in "${preserve_items[@]}"; do + if [ "$item" = "$preserve_item" ]; then + should_preserve=true + break + fi + done + + if [ "$should_preserve" = false ]; then + echo " ๐Ÿ—‘๏ธ Removing hidden: $item" + rm -rf "$item" + else + echo " ๐Ÿ“ Preserving hidden: $item" fi - done - rm -rf .temp_backup - fi + fi + done echo "โœ… Cleanup completed!" echo "๐Ÿ“ Remaining files after cleanup:" From cb24a6a5f51179bc82826760f23ead97ab61c879 Mon Sep 17 00:00:00 2001 From: yuri <8012032+yurisasuke@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:03:18 +0300 Subject: [PATCH 4/4] Update deploy-docs.yml --- .github/workflows/deploy-docs.yml | 133 ++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 45 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 3eeae97a8..c9aa8e71f 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -119,60 +119,103 @@ jobs: echo "๐Ÿ”„ Starting branch cloning and organization..." - # Read the branches config and extract branch information - branches=$(python3 -c "import json; config=json.load(open('branches-config.json')); [print(f\"{v.get('folder','')}:{v.get('branch','main')}\") for v in config.get('versions',[]) if v.get('folder','')]") + # Process each version from branches-config.json + python3 -c " + import json + import sys + + config = json.load(open('branches-config.json')) + versions = config.get('versions', []) + + for v in versions: + branch = v.get('branch', 'main') + is_latest = v.get('isLatest', False) + folder = v.get('folder', '') + + # Skip external versions + if v.get('isExternal', False): + continue + + if is_latest: + # Latest goes to root + print(f'root:{branch}') + elif folder: + # Non-latest with folder goes to that folder + print(f'{folder}:{branch}') + " > branch_list.txt echo "๐Ÿ“‹ Branches to process:" - echo "$branches" - - # Clone each branch into its respective folder - for branch_info in $branches; do - if [ -n "$branch_info" ]; then - folder=$(echo $branch_info | cut -d':' -f1) - branch=$(echo $branch_info | cut -d':' -f2) - - echo "๐Ÿ“‚ Processing $folder from branch $branch..." - - # Remove existing folder if it exists - if [ -d "$folder" ]; then - echo "๐Ÿ—‘๏ธ Removing existing $folder/" - rm -rf "$folder" - fi + cat branch_list.txt + # Process each branch + while IFS=':' read -r target_dir branch_name; do + if [ -n "$target_dir" ] && [ -n "$branch_name" ]; then + echo "๐Ÿ“‚ Processing $target_dir from branch $branch_name..." + # Create temporary directory for this branch - temp_dir="temp_$folder" - + temp_dir="temp_${target_dir}_${branch_name}" + # Clone the specific branch - echo "โฌ‡๏ธ Cloning branch $branch into $temp_dir..." - git clone --single-branch --branch "$branch" --depth 1 \ + echo "โฌ‡๏ธ Cloning branch $branch_name into $temp_dir..." + git clone --single-branch --branch "$branch_name" --depth 1 \ "https://github.com/${{ github.repository }}.git" "$temp_dir" - - # Move the contents (excluding .git) to the target folder - mkdir -p "$folder" - echo "๐Ÿ“ Moving contents from $temp_dir to $folder..." - - # Copy documentation content only, excluding development/build files - # Excluded: .git, scripts/, branches-config.json, .github/, README.md, .gitignore, .devcontainer/ - find "$temp_dir" -mindepth 1 -maxdepth 1 \ - ! -name '.git' \ - ! -name 'scripts' \ - ! -name 'branches-config.json' \ - ! -name '.github' \ - ! -name 'README.md' \ - ! -name '.gitignore' \ - ! -name '.devcontainer' \ - -exec cp -r {} "$folder/" \; - + + if [ "$target_dir" = "root" ]; then + # For root (latest), copy directly to current directory + echo "๐Ÿ“ Moving contents from $temp_dir to root..." + + # Copy documentation content only, excluding development/build files + find "$temp_dir" -mindepth 1 -maxdepth 1 \ + ! -name '.git' \ + ! -name 'scripts' \ + ! -name 'branches-config.json' \ + ! -name '.github' \ + ! -name 'README.md' \ + ! -name '.gitignore' \ + ! -name '.devcontainer' \ + ! -name '.vale' \ + -exec cp -r {} . \; + + echo "โœ… Successfully organized root from branch $branch_name" + echo "๐Ÿ“‹ Contents of root:" + ls -la | head -10 + else + # For non-root, create the target directory and copy there + echo "๐Ÿ“ Moving contents from $temp_dir to $target_dir..." + + # Remove existing folder if it exists + if [ -d "$target_dir" ]; then + echo "๐Ÿ—‘๏ธ Removing existing $target_dir/" + rm -rf "$target_dir" + fi + + # Create target directory + mkdir -p "$target_dir" + + # Copy documentation content only, excluding development/build files + find "$temp_dir" -mindepth 1 -maxdepth 1 \ + ! -name '.git' \ + ! -name 'scripts' \ + ! -name 'branches-config.json' \ + ! -name '.github' \ + ! -name 'README.md' \ + ! -name '.gitignore' \ + ! -name '.devcontainer' \ + ! -name '.vale' \ + -exec cp -r {} "$target_dir/" \; + + echo "โœ… Successfully organized $target_dir from branch $branch_name" + echo "๐Ÿ“‹ Contents of $target_dir:" + ls -la "$target_dir/" | head -10 + fi + # Clean up temp directory rm -rf "$temp_dir" - - echo "โœ… Successfully organized $folder from branch $branch" - - # Show what was copied - echo "๐Ÿ“‹ Contents of $folder:" - ls -la "$folder/" | head -10 fi - done + done < branch_list.txt + + # Clean up the branch list file + rm -f branch_list.txt echo "๐ŸŽ‰ All branches cloned and organized!"