11name : Deploy GitHub Pages Federation
22
3- # Unified atomic workflow for deploying both corporate site and documentation
4- # Solves race condition by deploying everything in a single atomic transaction
3+ # Simplified workflow for full federation rebuild
4+ # Always rebuilds both corporate site and documentation for reliability
55
66on :
7- # Triggered by corporate site updates
7+ # Triggered by any content updates
88 repository_dispatch :
99 types :
1010 - corporate-site-updated
1313 - web-terminal-docs-updated
1414 - cli-docs-updated
1515
16- # Manual trigger with options
16+ # Manual trigger with debug option
1717 workflow_dispatch :
1818 inputs :
19- rebuild_corporate :
20- description : ' Rebuild corporate site'
21- type : boolean
22- default : true
23- rebuild_docs :
24- description : ' Rebuild documentation'
25- type : boolean
26- default : true
2719 debug :
2820 description : ' Enable debug mode'
2921 type : boolean
4840
4941 steps :
5042 # ==========================================
51- # PHASE 1: Download Current State
52- # ==========================================
53- - name : Download Current GitHub Pages State
54- uses : actions/checkout@v4
55- with :
56- ref : gh-pages
57- path : current-site
58- continue-on-error : true
59-
60- - name : Validate Current State & Apply Fallback
61- run : |
62- echo "📦 Checking current site state..."
63-
64- # Check if we have valid current site content
65- if [ -d "current-site" ] && [ -n "$(ls -A current-site 2>/dev/null)" ]; then
66- echo "✅ Current site downloaded"
67- echo "📊 Current site size: $(du -sh current-site | cut -f1)"
68-
69- if [ -f "current-site/index.html" ]; then
70- echo "✅ Corporate site exists"
71- fi
72-
73- if [ -d "current-site/docs" ]; then
74- echo "✅ Docs directory exists: $(du -sh current-site/docs | cut -f1)"
75- fi
76-
77- # Valid current site found
78- echo "FALLBACK_TO_FULL=false" >> $GITHUB_ENV
79- else
80- echo "⚠️ No existing site found (fresh deployment or gh-pages branch missing)"
81- echo "🔄 Will use full rebuild strategy as fallback"
82- mkdir -p current-site
83-
84- # Set fallback flag
85- echo "FALLBACK_TO_FULL=true" >> $GITHUB_ENV
86- fi
87-
88- # ==========================================
89- # PHASE 2: Setup Build Environment
43+ # PHASE 1: Setup Build Environment
9044 # ==========================================
9145 - name : Checkout Hub Repository (for configs)
9246 uses : actions/checkout@v4
@@ -119,76 +73,15 @@ jobs:
11973 echo "✅ Hugo Templates ready"
12074
12175 # ==========================================
122- # PHASE 3: Determine Federation Strategy
123- # ==========================================
124- - name : Determine Federation Strategy
125- id : build-strategy
126- run : |
127- echo "🎯 Determining federation build strategy..."
128-
129- TRIGGER="${{ github.event_name }}"
130- EVENT_TYPE="${{ github.event.action }}"
131-
132- if [ "$TRIGGER" = "workflow_dispatch" ]; then
133- # Manual trigger - full rebuild
134- echo "📢 Manual trigger - full rebuild"
135- STRATEGY="merge-and-build"
136- BUILD_CORPORATE="${{ github.event.inputs.rebuild_corporate }}"
137- BUILD_DOCS="${{ github.event.inputs.rebuild_docs }}"
138- # Apply defaults
139- BUILD_CORPORATE="${BUILD_CORPORATE:-true}"
140- BUILD_DOCS="${BUILD_DOCS:-true}"
141-
142- elif [ "$TRIGGER" = "repository_dispatch" ]; then
143- if [ "$EVENT_TYPE" = "corporate-site-updated" ]; then
144- # Corporate update - full rebuild
145- echo "📢 Corporate site update - full rebuild"
146- STRATEGY="merge-and-build"
147- BUILD_CORPORATE="true"
148- BUILD_DOCS="true"
149- else
150- # Documentation update - incremental
151- echo "📢 Documentation update ($EVENT_TYPE) - incremental with preservation"
152- STRATEGY="preserve-base-site"
153- BUILD_CORPORATE="false"
154- BUILD_DOCS="true"
155- fi
156- else
157- echo "❌ Unknown trigger: $TRIGGER"
158- exit 1
159- fi
160-
161- # CRITICAL FIX: Apply fallback strategy if base site unavailable
162- if [ "$STRATEGY" = "preserve-base-site" ] && [ "$FALLBACK_TO_FULL" = "true" ]; then
163- echo "⚠️ Base site unavailable - switching to full rebuild strategy"
164- echo "🔄 Fallback: preserve-base-site → merge-and-build"
165- STRATEGY="merge-and-build"
166- BUILD_CORPORATE="true" # Must rebuild corporate site too
167- BUILD_DOCS="true"
168- fi
169-
170- echo "strategy=$STRATEGY" >> $GITHUB_OUTPUT
171- echo "build_corporate=$BUILD_CORPORATE" >> $GITHUB_OUTPUT
172- echo "build_docs=$BUILD_DOCS" >> $GITHUB_OUTPUT
173-
174- echo ""
175- echo "📋 Federation Strategy:"
176- echo " - Strategy: $STRATEGY"
177- echo " - Corporate: $BUILD_CORPORATE"
178- echo " - Documentation: $BUILD_DOCS"
179-
180- # ==========================================
181- # PHASE 4: Build Corporate Site (Conditional)
76+ # PHASE 2: Build Corporate Site
18277 # ==========================================
18378 - name : Clone Corporate Content
184- if : steps.build-strategy.outputs.build_corporate == 'true'
18579 run : |
18680 echo "📥 Cloning corporate content repository..."
18781 git clone https://github.com/info-tech-io/info-tech.git info-tech
18882 echo "✅ Corporate content cloned"
18983
19084 - name : Build Corporate Site
191- if : steps.build-strategy.outputs.build_corporate == 'true'
19285 run : |
19386 echo "🏗️ Building corporate site..."
19487
@@ -219,7 +112,6 @@ jobs:
219112 echo "✅ Corporate site built"
220113
221114 - name : Validate Corporate Build
222- if : steps.build-strategy.outputs.build_corporate == 'true'
223115 run : |
224116 echo "🔍 Validating corporate build..."
225117
@@ -233,90 +125,27 @@ jobs:
233125 echo "📦 Build size: $(du -sh corporate-build | cut -f1)"
234126
235127 # ==========================================
236- # PHASE 5 : Build Documentation (Conditional)
128+ # PHASE 3 : Build Documentation
237129 # ==========================================
238130 - name : Run Federation Build
239- if : steps.build-strategy.outputs.build_docs == 'true'
240131 env :
241132 GITHUB_TOKEN : ${{ secrets.PAT_TOKEN }}
242133 run : |
243134 echo "🚀 Running Hugo Templates federated build..."
244135
245136 cd hugo-templates
246137
247- STRATEGY="${{ steps.build-strategy.outputs.strategy }}"
248-
249- if [ "$STRATEGY" = "preserve-base-site" ]; then
250- echo "🔄 Incremental build - using existing current-site as base"
251-
252- # КЛЮЧЕВОЕ ИСПРАВЛЕНИЕ: Создать временную конфигурацию с current-site как local source
253- echo "📄 Creating temporary federation config with local base site..."
254-
255- # Создать правильную структуру для local source
256- mkdir -p ../current-site/content
257- # Переместить все файлы в content поддиректорию
258- find ../current-site -maxdepth 1 -type f -exec mv {} ../current-site/content/ \;
259-
260- # Создать минимальный module.json для current-site
261- echo '{
262- "module": {
263- "name": "base-site",
264- "version": "1.0.0",
265- "description": "Current GitHub Pages content (downloaded)"
266- },
267- "build": {
268- "template": "corporate",
269- "theme": "compose",
270- "copy_static": true
271- }
272- }' > ../current-site/module.json
273-
274- # Создать модифицированную конфигурацию
275- jq --arg current_site_path "$(pwd)/../current-site" '
276- .federation.strategy = "download-merge-deploy" |
277- .modules = [
278- {
279- "name": "base-site",
280- "source": {
281- "repository": "local",
282- "local_path": $current_site_path,
283- "path": "content",
284- "branch": "main"
285- },
286- "module_json": "module.json",
287- "destination": "/",
288- "css_path_prefix": ""
289- }
290- ] + .modules
291- ' ../hub-repo/configs/documentation-modules.json > ../temp-preserve-config.json
292-
293- echo "✅ Temporary config created with current-site as base module"
294-
295- ./scripts/federated-build.sh \
296- --config=../temp-preserve-config.json \
297- --output=../docs-build \
298- --verbose \
299- ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
300- else
301- echo "🔄 Full rebuild - building everything"
302- ./scripts/federated-build.sh \
303- --config=../hub-repo/configs/documentation-modules.json \
304- --output=../docs-build \
305- --verbose \
306- ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
307- fi
308-
309- # Cleanup temporary files
310- if [ -f "../temp-preserve-config.json" ]; then
311- rm -f ../temp-preserve-config.json
312- echo "🧹 Cleaned up temporary config"
313- fi
138+ echo "🔄 Full rebuild - building all documentation"
139+ ./scripts/federated-build.sh \
140+ --config=../hub-repo/configs/documentation-modules.json \
141+ --output=../docs-build \
142+ --verbose \
143+ ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
314144
315145 cd ..
316146 echo "✅ Federation build complete"
317147
318148 - name : Validate Documentation Build
319- if : steps.build-strategy.outputs.build_docs == 'true'
320149 run : |
321150 echo "🔍 Validating documentation builds..."
322151
@@ -339,7 +168,6 @@ jobs:
339168 echo "✅ All documentation validated"
340169
341170 - name : Create Documentation Hub
342- if : steps.build-strategy.outputs.build_docs == 'true'
343171 run : |
344172 echo "🏠 Creating documentation hub..."
345173
@@ -429,53 +257,31 @@ jobs:
429257 echo "✅ Documentation hub created"
430258
431259 # ==========================================
432- # PHASE 6 : Prepare Final Site
260+ # PHASE 4 : Prepare Final Site
433261 # ==========================================
434262 - name : Prepare Final Site Structure
435263 run : |
436- echo "📦 Preparing final site from federation build ..."
264+ echo "📦 Preparing final site by combining corporate and documentation ..."
437265
438- STRATEGY="${{ steps.build-strategy.outputs.strategy }}"
266+ mkdir -p final-site
439267
440- if [ "$STRATEGY" = "preserve-base-site" ]; then
441- # For incremental updates, federated-build.sh already handled content preservation
442- echo "🔄 Using federated build output (content already preserved)"
443-
444- if [ -d "docs-build" ]; then
445- mv docs-build final-site
446- echo "✅ Federation output moved to final-site"
447- else
448- echo "❌ Federation build output not found!"
449- exit 1
450- fi
268+ # Add corporate site
269+ echo "📋 Adding corporate site..."
270+ rsync -av corporate-build/ final-site/
271+ echo "✅ Corporate site added"
451272
273+ # Add documentation
274+ echo "📋 Adding documentation..."
275+ if [ -d "docs-build/docs" ]; then
276+ # If docs-build contains docs/, copy it
277+ mkdir -p final-site/docs
278+ rsync -av docs-build/docs/ final-site/docs/
452279 else
453- # For full rebuilds, combine corporate and docs
454- echo "🔄 Combining corporate site and documentation"
455- mkdir -p final-site
456-
457- # Add corporate site if built
458- if [ "${{ steps.build-strategy.outputs.build_corporate }}" = "true" ] && [ -d "corporate-build" ]; then
459- echo "📋 Adding corporate site..."
460- rsync -av corporate-build/ final-site/
461- echo "✅ Corporate site added"
462- fi
463-
464- # Add documentation if built
465- if [ "${{ steps.build-strategy.outputs.build_docs }}" = "true" ] && [ -d "docs-build" ]; then
466- echo "📋 Adding documentation..."
467- if [ -d "docs-build/docs" ]; then
468- # If docs-build contains docs/, copy it
469- mkdir -p final-site/docs
470- rsync -av docs-build/docs/ final-site/docs/
471- else
472- # If docs-build is the docs content, copy it to /docs/
473- mkdir -p final-site/docs
474- rsync -av docs-build/ final-site/docs/
475- fi
476- echo "✅ Documentation added"
477- fi
280+ # If docs-build is the docs content, copy it to /docs/
281+ mkdir -p final-site/docs
282+ rsync -av docs-build/ final-site/docs/
478283 fi
284+ echo "✅ Documentation added"
479285
480286 echo "✅ Final site preparation complete"
481287
@@ -538,25 +344,25 @@ jobs:
538344 echo "🌐 URL: ${{ steps.deployment.outputs.page_url }}"
539345 echo ""
540346 echo "📋 Deployment Summary:"
541- echo " - Corporate site: ${{ steps.build-targets.outputs.build_corporate == 'true' && ' Updated ✅' || 'Preserved ✅' }} "
542- echo " - Documentation: ${{ steps.build-targets.outputs.build_docs == 'true' && ' Updated ✅' || 'Preserved ✅' }} "
543- echo " - Deployment mode: Atomic (single transaction )"
347+ echo " - Corporate site: Updated ✅"
348+ echo " - Documentation: Updated ✅"
349+ echo " - Deployment mode: Full rebuild (simplified strategy )"
544350 echo " - Concurrency: Serialized via unified group"
545351
546352 # ==========================================
547- # PHASE 8 : Error Handling
353+ # PHASE 5 : Error Handling
548354 # ==========================================
549355 - name : Cleanup on Failure
550356 if : failure()
551357 run : |
552358 echo "❌ Workflow failed!"
553359 echo "🧹 Cleaning up temporary files..."
554- rm -rf corporate-build docs-build current-site final-site hugo-templates info-tech hub-repo
360+ rm -rf corporate-build docs-build final-site hugo-templates info-tech hub-repo
555361 echo "✅ Cleanup complete"
556362
557363 - name : Notify on Failure
558364 if : failure()
559365 run : |
560366 echo "::error::GitHub Pages deployment failed. Check logs for details."
561367 echo "::error::Failed job: ${{ github.job }}"
562- echo "::error::Build targets: Corporate=${{ steps. build-targets.outputs.build_corporate }}, Docs=${{ steps.build-targets.outputs.build_docs }} "
368+ echo "::error::Strategy: Full rebuild (always build both corporate and documentation) "
0 commit comments