You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/deploy-docs.yml
+97-70Lines changed: 97 additions & 70 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ on:
4
4
workflow_dispatch:
5
5
inputs:
6
6
subfolder:
7
-
description: 'Subfolder for documentation (e.g., docs3, docsv3, docs)'
7
+
description: 'Subfolder for documentation (leave empty for root deployment)'
8
8
required: false
9
-
default: 'docs3'
9
+
default: ''
10
10
type: string
11
11
12
12
# Ensure only latest deployment runs
@@ -48,77 +48,68 @@ jobs:
48
48
49
49
- name: Cleanup old version folders and assets
50
50
run: |
51
-
echo "🧹 Cleaning up old version folders and assets..."
52
-
53
-
# Get current version folders from config
54
-
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))")
55
-
56
-
echo "📋 Current version folders: $current_folders"
57
-
58
-
# Define asset types that will be regenerated
59
-
asset_types=(
60
-
"style.css"
61
-
"images"
62
-
"img"
63
-
"logo"
64
-
"favicon.ico"
65
-
"favicon.png"
66
-
"snippets"
51
+
echo "🧹 Cleaning up all content except essential files..."
52
+
53
+
# Define folders to keep (whitelist)
54
+
keep_folders=(
55
+
".github"
56
+
".git"
57
+
".devcontainer"
58
+
"scripts"
59
+
".vale"
67
60
)
68
61
69
-
# Remove old assets (they'll be regenerated from current versions)
70
-
echo "🎨 Cleaning up old assets..."
71
-
for asset in "${asset_types[@]}"; do
72
-
if [ -e "$asset" ]; then
73
-
echo "🗑️ Removing old asset: $asset"
74
-
rm -rf "$asset"
75
-
fi
76
-
done
77
-
78
-
# Remove old docs.json (will be regenerated)
79
-
if [ -f "docs.json" ]; then
80
-
echo "🗑️ Removing old docs.json"
81
-
rm -f "docs.json"
82
-
fi
62
+
# Define files to keep (whitelist)
63
+
keep_files=(
64
+
"branches-config.json"
65
+
".gitignore"
66
+
"README.md"
67
+
".vale.ini"
68
+
)
83
69
84
-
# Also clean up the subfolder if it exists (using input parameter)
85
-
SUBFOLDER="${{ inputs.subfolder || 'docs3' }}"
86
-
if [ -n "$SUBFOLDER" ] && [ -d "$SUBFOLDER" ]; then
87
-
echo "🗑️ Removing old $SUBFOLDER subfolder"
88
-
rm -rf "$SUBFOLDER"
89
-
fi
70
+
echo "📋 Folders to keep: ${keep_folders[*]}"
71
+
echo "📋 Files to keep: ${keep_files[*]}"
90
72
91
-
# Remove old version folders that aren't in the current config
92
-
# Look for directories that look like version folders (numeric or version-like names)
73
+
# Remove all directories except the ones we want to keep
74
+
echo "🗑️ Removing old directories..."
93
75
for dir in */; do
94
76
if [ -d "$dir" ]; then
95
77
dir_name=${dir%/} # Remove trailing slash
96
-
97
-
# Skip non-version directories
98
-
if [[ "$dir_name" =~ ^\..*$ ]] || [ "$dir_name" = ".github" ]; then
99
-
continue
100
-
fi
101
-
102
-
# Check if this folder is in current config
103
-
is_current=false
104
-
for current in $current_folders; do
105
-
if [ "$dir_name" = "$current" ]; then
106
-
is_current=true
78
+
79
+
should_keep=false
80
+
for keep_folder in "${keep_folders[@]}"; do
81
+
if [ "$dir_name" = "$keep_folder" ]; then
82
+
should_keep=true
107
83
break
108
84
fi
109
85
done
86
+
87
+
if [ "$should_keep" = false ]; then
88
+
echo "🗑️ Removing directory: $dir_name/"
89
+
rm -rf "$dir"
90
+
else
91
+
echo "📁 Keeping essential directory: $dir_name/"
92
+
fi
93
+
fi
94
+
done
110
95
111
-
# If it's not in current config and looks like a version folder, remove it
112
-
if [ "$is_current" = false ]; then
113
-
# Only remove if it looks like a version folder (contains numbers/dots or common version patterns)
114
-
if [[ "$dir_name" =~ ^[0-9]+\.[0-9]+$ ]] || [[ "$dir_name" =~ ^v[0-9] ]] || [[ "$dir_name" =~ ^[0-9] ]]; then
115
-
echo "🗑️ Removing old version folder: $dir_name"
116
-
rm -rf "$dir"
117
-
else
118
-
echo "📁 Keeping non-version directory: $dir_name"
96
+
# Remove all files except the ones we want to keep
97
+
echo "🗑️ Removing old files..."
98
+
for file in *; do
99
+
if [ -f "$file" ]; then
100
+
should_keep=false
101
+
for keep_file in "${keep_files[@]}"; do
102
+
if [ "$file" = "$keep_file" ]; then
103
+
should_keep=true
104
+
break
119
105
fi
106
+
done
107
+
108
+
if [ "$should_keep" = false ]; then
109
+
echo "🗑️ Removing file: $file"
110
+
rm -f "$file"
120
111
else
121
-
echo "📁 Keeping current version folder: $dir_name (will be refreshed)"
112
+
echo "📄 Keeping essential file: $file"
122
113
fi
123
114
fi
124
115
done
@@ -134,7 +125,7 @@ jobs:
134
125
echo "🔄 Starting branch cloning and organization..."
135
126
136
127
# Read the branches config and extract branch information
137
-
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','')]")
128
+
branches=$(python3 -c "import json; config=json.load(open('branches-config.json')); [print(f\"{v.get('sourceFolder','')}:{v.get('branch','main')}\") for v in config.get('versions',[]) if v.get('sourceFolder','')]")
138
129
139
130
echo "📋 Branches to process:"
140
131
echo "$branches"
@@ -194,18 +185,20 @@ jobs:
194
185
run: |
195
186
echo "🔄 Running documentation merger..."
196
187
197
-
# Get subfolder from input (with fallback)
198
-
SUBFOLDER="${{ inputs.subfolder || 'docs3' }}"
199
-
echo "📁 Using subfolder: $SUBFOLDER"
188
+
# Get subfolder from input (no fallback - empty means root deployment)
189
+
SUBFOLDER="${{ inputs.subfolder }}"
190
+
echo "📁 Using subfolder: '$SUBFOLDER'"
200
191
201
192
# Run the merge script with branches config
202
193
if [ -n "$SUBFOLDER" ]; then
194
+
echo "📁 Deploying to subfolder: $SUBFOLDER"
203
195
python3 scripts/merge_docs_configs.py \
204
196
--branches-config branches-config.json \
205
197
--base-dir . \
206
198
--subfolder "$SUBFOLDER" \
207
199
--output docs.json
208
200
else
201
+
echo "📁 Deploying to root (no subfolder)"
209
202
python3 scripts/merge_docs_configs.py \
210
203
--branches-config branches-config.json \
211
204
--base-dir . \
@@ -219,7 +212,7 @@ jobs:
219
212
echo "🧹 Cleaning up temporary cloned version folders..."
220
213
221
214
# Get current version folders from config
222
-
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))")
215
+
current_folders=$(python3 -c "import json; config=json.load(open('branches-config.json')); folders=[v.get('sourceFolder','') for v in config.get('versions',[]) if v.get('sourceFolder','')]; print(' '.join(folders))")
0 commit comments