@@ -111,57 +111,67 @@ jobs:
111111 echo "✅ Hugo Templates ready"
112112
113113 # ==========================================
114- # PHASE 3: Determine What to Build
114+ # PHASE 3: Determine Federation Strategy
115115 # ==========================================
116- - name : Determine Build Targets
117- id : build-targets
116+ - name : Determine Federation Strategy
117+ id : build-strategy
118118 run : |
119- echo "🎯 Determining what needs to be rebuilt ..."
119+ echo "🎯 Determining federation build strategy ..."
120120
121- # Check trigger type
122121 TRIGGER="${{ github.event_name }}"
123122 EVENT_TYPE="${{ github.event.action }}"
124123
125- # Defaults for workflow_dispatch
126- BUILD_CORPORATE="${{ github.event.inputs.rebuild_corporate }}"
127- BUILD_DOCS="${{ github.event.inputs.rebuild_docs }}"
128-
129- # For repository_dispatch, determine based on event type
130- if [ "$TRIGGER" = "repository_dispatch" ]; then
124+ if [ "$TRIGGER" = "workflow_dispatch" ]; then
125+ # Manual trigger - full rebuild
126+ echo "📢 Manual trigger - full rebuild"
127+ STRATEGY="merge-and-build"
128+ BUILD_CORPORATE="${{ github.event.inputs.rebuild_corporate }}"
129+ BUILD_DOCS="${{ github.event.inputs.rebuild_docs }}"
130+ # Apply defaults
131+ BUILD_CORPORATE="${BUILD_CORPORATE:-true}"
132+ BUILD_DOCS="${BUILD_DOCS:-true}"
133+
134+ elif [ "$TRIGGER" = "repository_dispatch" ]; then
131135 if [ "$EVENT_TYPE" = "corporate-site-updated" ]; then
136+ # Corporate update - full rebuild
137+ echo "📢 Corporate site update - full rebuild"
138+ STRATEGY="merge-and-build"
132139 BUILD_CORPORATE="true"
133- BUILD_DOCS="false"
134- echo "📢 Triggered by corporate site update"
140+ BUILD_DOCS="true"
135141 else
142+ # Documentation update - incremental
143+ echo "📢 Documentation update ($EVENT_TYPE) - incremental with preservation"
144+ STRATEGY="preserve-base-site"
136145 BUILD_CORPORATE="false"
137146 BUILD_DOCS="true"
138- echo "📢 Triggered by documentation update ($EVENT_TYPE)"
139147 fi
148+ else
149+ echo "❌ Unknown trigger: $TRIGGER"
150+ exit 1
140151 fi
141152
142- # Default to true if not set
143- BUILD_CORPORATE="${BUILD_CORPORATE:-true}"
144- BUILD_DOCS="${BUILD_DOCS:-true}"
145-
153+ echo "strategy=$STRATEGY" >> $GITHUB_OUTPUT
146154 echo "build_corporate=$BUILD_CORPORATE" >> $GITHUB_OUTPUT
147155 echo "build_docs=$BUILD_DOCS" >> $GITHUB_OUTPUT
148156
149- echo "📋 Build plan:"
150- echo " - Corporate site: $BUILD_CORPORATE"
157+ echo ""
158+ echo "📋 Federation Strategy:"
159+ echo " - Strategy: $STRATEGY"
160+ echo " - Corporate: $BUILD_CORPORATE"
151161 echo " - Documentation: $BUILD_DOCS"
152162
153163 # ==========================================
154164 # PHASE 4: Build Corporate Site (Conditional)
155165 # ==========================================
156166 - name : Clone Corporate Content
157- if : steps.build-targets .outputs.build_corporate == 'true'
167+ if : steps.build-strategy .outputs.build_corporate == 'true'
158168 run : |
159169 echo "📥 Cloning corporate content repository..."
160170 git clone https://github.com/info-tech-io/info-tech.git info-tech
161171 echo "✅ Corporate content cloned"
162172
163173 - name : Build Corporate Site
164- if : steps.build-targets .outputs.build_corporate == 'true'
174+ if : steps.build-strategy .outputs.build_corporate == 'true'
165175 run : |
166176 echo "🏗️ Building corporate site..."
167177
@@ -192,7 +202,7 @@ jobs:
192202 echo "✅ Corporate site built"
193203
194204 - name : Validate Corporate Build
195- if : steps.build-targets .outputs.build_corporate == 'true'
205+ if : steps.build-strategy .outputs.build_corporate == 'true'
196206 run : |
197207 echo "🔍 Validating corporate build..."
198208
@@ -208,27 +218,39 @@ jobs:
208218 # ==========================================
209219 # PHASE 5: Build Documentation (Conditional)
210220 # ==========================================
211- - name : Build All Product Documentation
212- if : steps.build-targets .outputs.build_docs == 'true'
221+ - name : Run Federation Build
222+ if : steps.build-strategy .outputs.build_docs == 'true'
213223 env :
214224 GITHUB_TOKEN : ${{ secrets.PAT_TOKEN }}
215225 run : |
216- echo "🏗️ Building all product documentation ..."
226+ echo "🚀 Running Hugo Templates federated build ..."
217227
218228 cd hugo-templates
219229
220- # Use federated-build.sh with documentation-modules.json
221- ./scripts/federated-build.sh \
222- --config=../hub-repo/configs/documentation-modules.json \
223- --output=../docs-build \
224- --verbose \
225- ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
230+ STRATEGY="${{ steps.build-strategy.outputs.strategy }}"
231+
232+ if [ "$STRATEGY" = "preserve-base-site" ]; then
233+ echo "🔄 Incremental build - preserving existing content"
234+ ./scripts/federated-build.sh \
235+ --config=../hub-repo/configs/documentation-modules.json \
236+ --output=../docs-build \
237+ --preserve-base-site \
238+ --verbose \
239+ ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
240+ else
241+ echo "🔄 Full rebuild - building everything"
242+ ./scripts/federated-build.sh \
243+ --config=../hub-repo/configs/documentation-modules.json \
244+ --output=../docs-build \
245+ --verbose \
246+ ${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
247+ fi
226248
227249 cd ..
228- echo "✅ All documentation built "
250+ echo "✅ Federation build complete "
229251
230252 - name : Validate Documentation Build
231- if : steps.build-targets .outputs.build_docs == 'true'
253+ if : steps.build-strategy .outputs.build_docs == 'true'
232254 run : |
233255 echo "🔍 Validating documentation builds..."
234256
@@ -251,7 +273,7 @@ jobs:
251273 echo "✅ All documentation validated"
252274
253275 - name : Create Documentation Hub
254- if : steps.build-targets .outputs.build_docs == 'true'
276+ if : steps.build-strategy .outputs.build_docs == 'true'
255277 run : |
256278 echo "🏠 Creating documentation hub..."
257279
@@ -341,90 +363,55 @@ jobs:
341363 echo "✅ Documentation hub created"
342364
343365 # ==========================================
344- # PHASE 6: Atomic Merge
366+ # PHASE 6: Prepare Final Site
345367 # ==========================================
346- - name : Atomic Merge - Combine All Content
368+ - name : Prepare Final Site Structure
347369 run : |
348- echo "🔄 Performing atomic merge of all content ..."
370+ echo "📦 Preparing final site from federation build ..."
349371
350- # Initialize final-site directory
351- mkdir -p final-site
372+ STRATEGY="${{ steps.build-strategy.outputs.strategy }}"
352373
353- # Step 1: Copy existing content as base
354- if [ -d "current-site" ] && [ "$(ls -A current-site 2>/dev/null)" ]; then
355- echo "📋 Using current site as base..."
356- rsync -av current-site/ final-site/
357- fi
374+ if [ "$STRATEGY" = "preserve-base-site" ]; then
375+ # For incremental updates, federated-build.sh already handled content preservation
376+ echo "🔄 Using federated build output (content already preserved)"
358377
359- # Step 2: Merge corporate site (if built)
360- if [ "${{ steps.build-targets.outputs.build_corporate }}" = "true" ] && [ -d "corporate-build" ]; then
361- echo "📋 Merging corporate site to root (excluding /docs/)..."
362- rsync -av --delete --exclude='docs/' corporate-build/ final-site/
363- echo "✅ Corporate site merged"
364- else
365- echo "⏭️ Skipping corporate site merge (not rebuilt)"
366- fi
378+ if [ -d "docs-build" ]; then
379+ mv docs-build final-site
380+ echo "✅ Federation output moved to final-site"
381+ else
382+ echo "❌ Federation build output not found!"
383+ exit 1
384+ fi
367385
368- # Step 3: Merge documentation (if built)
369- if [ "${{ steps.build-targets.outputs.build_docs }}" = "true" ] && [ -d "docs-build/docs" ]; then
370- echo "📋 Merging documentation to /docs/..."
371- mkdir -p final-site/docs
372- rsync -av --delete docs-build/docs/ final-site/docs/
373- echo "✅ Documentation merged"
374386 else
375- echo "⏭️ Skipping documentation merge (not rebuilt)"
376- fi
387+ # For full rebuilds, combine corporate and docs
388+ echo "🔄 Combining corporate site and documentation"
389+ mkdir -p final-site
390+
391+ # Add corporate site if built
392+ if [ "${{ steps.build-strategy.outputs.build_corporate }}" = "true" ] && [ -d "corporate-build" ]; then
393+ echo "📋 Adding corporate site..."
394+ rsync -av corporate-build/ final-site/
395+ echo "✅ Corporate site added"
396+ fi
377397
378- # Step 4: Ensure /docs/ exists with fallback
379- if [ ! -d "final-site/docs" ]; then
380- echo "📁 Creating /docs/ directory with fallback index..."
381- mkdir -p final-site/docs
382- cat > final-site/docs/index.html <<'FALLBACK'
383- <!DOCTYPE html>
384- <html lang="en">
385- <head>
386- <meta charset="UTF-8">
387- <meta name="viewport" content="width=device-width, initial-scale=1.0">
388- <title>Documentation - InfoTech.io</title>
389- <style>
390- body {
391- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
392- margin: 0;
393- padding: 40px;
394- text-align: center;
395- background: #fafafa;
396- }
397- .container {
398- max-width: 600px;
399- margin: 0 auto;
400- background: white;
401- border-radius: 12px;
402- padding: 40px;
403- box-shadow: 0 2px 20px rgba(0,0,0,0.1);
404- }
405- .header { color: #333; margin-bottom: 20px; }
406- .message { color: #666; margin-bottom: 30px; line-height: 1.6; }
407- .link { color: #1da1f2; text-decoration: none; font-weight: 600; }
408- .link:hover { text-decoration: underline; }
409- </style>
410- </head>
411- <body>
412- <div class="container">
413- <h1 class="header">📚 Documentation Hub</h1>
414- <p class="message">
415- Product documentation will be available here soon.<br>
416- Check back later for updates.
417- </p>
418- <p>
419- <a href="/" class="link">🏠 Back to Main Site</a>
420- </p>
421- </div>
422- </body>
423- </html>
424- FALLBACK
398+ # Add documentation if built
399+ if [ "${{ steps.build-strategy.outputs.build_docs }}" = "true" ] && [ -d "docs-build" ]; then
400+ echo "📋 Adding documentation..."
401+ if [ -d "docs-build/docs" ]; then
402+ # If docs-build contains docs/, copy it
403+ mkdir -p final-site/docs
404+ rsync -av docs-build/docs/ final-site/docs/
405+ else
406+ # If docs-build is the docs content, copy it to /docs/
407+ mkdir -p final-site/docs
408+ rsync -av docs-build/ final-site/docs/
409+ fi
410+ echo "✅ Documentation added"
411+ fi
425412 fi
426413
427- echo "✅ Atomic merge complete"
414+ echo "✅ Final site preparation complete"
428415
429416 - name : Verify Final Site Structure
430417 run : |
0 commit comments