-
Notifications
You must be signed in to change notification settings - Fork 0
361 lines (315 loc) · 12.9 KB
/
deploy-github-pages.yml
File metadata and controls
361 lines (315 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: Deploy GitHub Pages Federation
# Simplified workflow for full federation rebuild
# Always rebuilds both corporate site and documentation for reliability
on:
# Triggered by any content updates
repository_dispatch:
types:
- corporate-site-updated
- quiz-docs-updated
- hugo-templates-docs-updated
- web-terminal-docs-updated
- cli-docs-updated
# Manual trigger with debug option
workflow_dispatch:
inputs:
debug:
description: 'Enable debug mode'
type: boolean
default: false
permissions:
contents: write
# Single concurrency group ensures atomic deployments
concurrency:
group: "github-pages-federation"
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# ==========================================
# PHASE 1: Setup Build Environment
# ==========================================
- name: Checkout Hub Repository (for configs)
uses: actions/checkout@v4
with:
path: hub-repo
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.148.0'
extended: true
- name: Clone Hugo Templates Framework
uses: actions/checkout@v4
with:
repository: info-tech-io/hugo-templates
token: ${{ secrets.PAT_TOKEN }}
path: hugo-templates
submodules: recursive
ref: main
- name: Prepare Hugo Templates
run: |
echo "🔧 Preparing Hugo Templates framework..."
cd hugo-templates
git submodule update --init --recursive
npm install || echo "⚠️ npm install failed, continuing..."
chmod +x scripts/build.sh scripts/federated-build.sh
cd ..
echo "✅ Hugo Templates ready"
# ==========================================
# PHASE 2: Build Corporate Site
# ==========================================
- name: Clone Corporate Content
run: |
echo "📥 Cloning corporate content repository..."
git clone https://github.com/info-tech-io/info-tech.git info-tech
echo "✅ Corporate content cloned"
- name: Build Corporate Site
run: |
echo "🏗️ Building corporate site..."
cd hugo-templates
# Copy corporate content to module-content
rm -rf module-content
cp -r ../info-tech/docs ./module-content
# Build corporate site
if [ "${{ github.event.inputs.debug }}" = "true" ]; then
./scripts/build.sh \
--config ./module-content/module.json \
--content ./module-content/content \
--output ../corporate-build \
--force \
--debug \
--verbose
else
./scripts/build.sh \
--config ./module-content/module.json \
--content ./module-content/content \
--output ../corporate-build \
--force
fi
cd ..
echo "✅ Corporate site built"
- name: Validate Corporate Build
run: |
echo "🔍 Validating corporate build..."
if [ ! -f "corporate-build/index.html" ]; then
echo "❌ Build failed: No index.html found"
exit 1
fi
html_count=$(find corporate-build -name '*.html' | wc -l)
echo "✅ Corporate build successful: $html_count HTML files"
echo "📦 Build size: $(du -sh corporate-build | cut -f1)"
# ==========================================
# PHASE 3: Build Documentation
# ==========================================
- name: Run Federation Build
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
echo "🚀 Running Hugo Templates federated build..."
cd hugo-templates
echo "🔄 Full rebuild - building all documentation"
./scripts/federated-build.sh \
--config=../hub-repo/configs/documentation-modules.json \
--output=../docs-build \
--verbose \
${{ github.event.inputs.debug == 'true' && '--debug' || '' }}
cd ..
echo "✅ Federation build complete"
- name: Validate Documentation Build
run: |
echo "🔍 Validating documentation builds..."
products=("quiz" "hugo-templates" "web-terminal" "info-tech-cli")
for product in "${products[@]}"; do
if [ -d "docs-build/docs/$product" ]; then
html_count=$(find "docs-build/docs/$product" -name '*.html' | wc -l)
echo " ✅ $product: $html_count HTML files"
if [ ! -f "docs-build/docs/$product/index.html" ]; then
echo " ⚠️ Warning: $product missing index.html"
fi
else
echo " ❌ $product: Build output missing"
exit 1
fi
done
echo "✅ All documentation validated"
- name: Create Documentation Hub
run: |
echo "🏠 Creating documentation hub..."
mkdir -p docs-build/docs
cat > docs-build/docs/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documentation Hub - InfoTech.io</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.6;
color: #14171a;
background: #ffffff;
}
header {
background: #14171a;
color: white;
padding: 2rem;
text-align: center;
}
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.subtitle { color: rgba(255,255,255,0.8); font-size: 1.1rem; }
.container { max-width: 1200px; margin: 3rem auto; padding: 0 2rem; }
.products { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; }
.card {
background: #f7f9fa;
border: 1px solid #e1e8ed;
border-radius: 12px;
padding: 2rem;
transition: transform 0.3s, box-shadow 0.3s;
text-decoration: none;
color: inherit;
display: block;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.icon { font-size: 3rem; margin-bottom: 1rem; }
.card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: #14171a; }
.card p { color: #657786; margin-bottom: 1rem; }
.link { color: #1da1f2; font-weight: 500; text-decoration: none; }
.back { display: inline-block; margin: 2rem 0; color: #1da1f2; text-decoration: none; }
</style>
</head>
<body>
<header>
<h1>📚 Documentation Hub</h1>
<p class="subtitle">Comprehensive documentation for all InfoTech.io products</p>
</header>
<main class="container">
<div class="products">
<a href="/docs/quiz/" class="card">
<div class="icon">🎯</div>
<h2>Quiz Engine</h2>
<p>Interactive quiz and assessment platform for creating engaging educational content</p>
<span class="link">View Documentation →</span>
</a>
<a href="/docs/hugo-templates/" class="card">
<div class="icon">🏗️</div>
<h2>Hugo Templates Framework</h2>
<p>Powerful Hugo-based static site generation framework with federated build capabilities</p>
<span class="link">View Documentation →</span>
</a>
<a href="/docs/web-terminal/" class="card">
<div class="icon">💻</div>
<h2>Web Terminal</h2>
<p>Browser-based terminal emulator for interactive command-line experiences</p>
<span class="link">View Documentation →</span>
</a>
<a href="/docs/info-tech-cli/" class="card">
<div class="icon">⚡</div>
<h2>InfoTech CLI</h2>
<p>Command-line interface for managing InfoTech.io projects and workflows</p>
<span class="link">View Documentation →</span>
</a>
</div>
<a href="/" class="back">← Back to Main Site</a>
</main>
</body>
</html>
EOF
echo "✅ Documentation hub created"
# ==========================================
# PHASE 4: Prepare Final Site
# ==========================================
- name: Prepare Final Site Structure
run: |
echo "📦 Preparing final site by combining corporate and documentation..."
mkdir -p final-site
# Add corporate site
echo "📋 Adding corporate site..."
rsync -av corporate-build/ final-site/
echo "✅ Corporate site added"
# Add documentation
echo "📋 Adding documentation..."
if [ -d "docs-build/docs" ]; then
# If docs-build contains docs/, copy it
mkdir -p final-site/docs
rsync -av docs-build/docs/ final-site/docs/
else
# If docs-build is the docs content, copy it to /docs/
mkdir -p final-site/docs
rsync -av docs-build/ final-site/docs/
fi
echo "✅ Documentation added"
echo "✅ Final site preparation complete"
- name: Verify Final Site Structure
run: |
echo "📊 Final site structure verification:"
echo ""
echo "=== Root directory ==="
if [ -f "final-site/index.html" ]; then
echo "✅ Corporate index.html present"
else
echo "⚠️ Corporate index.html missing"
fi
echo ""
echo "=== Documentation (/docs/) ==="
if [ -d "final-site/docs" ]; then
echo "✅ /docs/ directory exists"
if [ -f "final-site/docs/index.html" ]; then
echo "✅ /docs/index.html present"
fi
products=("quiz" "hugo-templates" "web-terminal" "info-tech-cli")
for product in "${products[@]}"; do
if [ -d "final-site/docs/$product" ]; then
files=$(find "final-site/docs/$product" -type f | wc -l)
echo " ✅ $product: $files files"
else
echo " ⚠️ $product: Not present"
fi
done
else
echo "❌ /docs/ directory missing!"
exit 1
fi
echo ""
echo "=== Final statistics ==="
echo "📦 Total size: $(du -sh final-site | cut -f1)"
echo "📄 Total files: $(find final-site -type f | wc -l)"
echo ""
echo "✅ Verification complete"
# ==========================================
# PHASE 7: Deploy to gh-pages branch
# ==========================================
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./final-site
publish_branch: gh-pages
- name: Deployment Success
run: |
echo "✅ GitHub Pages federation deployed successfully!"
echo "🌐 URL: https://info-tech-io.github.io"
echo ""
echo "📋 Deployment Summary:"
echo " - Corporate site: Updated ✅"
echo " - Documentation: Updated ✅"
echo " - Deployment mode: Full rebuild (simplified strategy)"
echo " - Concurrency: Serialized via unified group"
# ==========================================
# PHASE 5: Error Handling
# ==========================================
- name: Cleanup on Failure
if: failure()
run: |
echo "❌ Workflow failed!"
echo "🧹 Cleaning up temporary files..."
rm -rf corporate-build docs-build final-site hugo-templates info-tech hub-repo
echo "✅ Cleanup complete"
- name: Notify on Failure
if: failure()
run: |
echo "::error::GitHub Pages deployment failed. Check logs for details."
echo "::error::Failed job: ${{ github.job }}"
echo "::error::Strategy: Full rebuild (always build both corporate and documentation)"