1+ name : Deploy InfoTech.io Sites
2+
3+ on :
4+ repository_dispatch :
5+ types : [
6+ corporate-site-updated,
7+ quiz-docs-updated,
8+ hugo-docs-updated,
9+ web-terminal-docs-updated,
10+ cli-docs-updated
11+ ]
12+ workflow_dispatch :
13+ inputs :
14+ site :
15+ description : ' Which site to rebuild (all, corporate, quiz, hugo, terminal, cli)'
16+ required : false
17+ default : ' all'
18+ push :
19+ branches :
20+ - main
21+
22+ permissions :
23+ contents : read
24+ pages : write
25+ id-token : write
26+
27+ concurrency :
28+ group : " pages"
29+ cancel-in-progress : false
30+
31+ jobs :
32+ determine-scope :
33+ runs-on : ubuntu-latest
34+ outputs :
35+ rebuild_corporate : ${{ steps.scope.outputs.rebuild_corporate }}
36+ rebuild_quiz : ${{ steps.scope.outputs.rebuild_quiz }}
37+ rebuild_hugo : ${{ steps.scope.outputs.rebuild_hugo }}
38+ rebuild_terminal : ${{ steps.scope.outputs.rebuild_terminal }}
39+ rebuild_cli : ${{ steps.scope.outputs.rebuild_cli }}
40+ steps :
41+ - name : Determine rebuild scope
42+ id : scope
43+ run : |
44+ echo "Event: ${{ github.event_name }}"
45+ echo "Event type: ${{ github.event.action }}"
46+
47+ # Default to rebuild all
48+ rebuild_corporate=true
49+ rebuild_quiz=true
50+ rebuild_hugo=true
51+ rebuild_terminal=true
52+ rebuild_cli=true
53+
54+ # Determine scope based on event
55+ case "${{ github.event.action }}" in
56+ corporate-site-updated)
57+ rebuild_corporate=true
58+ rebuild_quiz=false
59+ rebuild_hugo=false
60+ rebuild_terminal=false
61+ rebuild_cli=false
62+ ;;
63+ quiz-docs-updated)
64+ rebuild_corporate=false
65+ rebuild_quiz=true
66+ rebuild_hugo=false
67+ rebuild_terminal=false
68+ rebuild_cli=false
69+ ;;
70+ hugo-docs-updated)
71+ rebuild_corporate=false
72+ rebuild_quiz=false
73+ rebuild_hugo=true
74+ rebuild_terminal=false
75+ rebuild_cli=false
76+ ;;
77+ web-terminal-docs-updated)
78+ rebuild_corporate=false
79+ rebuild_quiz=false
80+ rebuild_hugo=false
81+ rebuild_terminal=true
82+ rebuild_cli=false
83+ ;;
84+ cli-docs-updated)
85+ rebuild_corporate=false
86+ rebuild_quiz=false
87+ rebuild_hugo=false
88+ rebuild_terminal=false
89+ rebuild_cli=true
90+ ;;
91+ esac
92+
93+ # Override with manual input if provided
94+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
95+ case "${{ github.event.inputs.site }}" in
96+ corporate)
97+ rebuild_corporate=true
98+ rebuild_quiz=false
99+ rebuild_hugo=false
100+ rebuild_terminal=false
101+ rebuild_cli=false
102+ ;;
103+ quiz)
104+ rebuild_corporate=false
105+ rebuild_quiz=true
106+ rebuild_hugo=false
107+ rebuild_terminal=false
108+ rebuild_cli=false
109+ ;;
110+ hugo)
111+ rebuild_corporate=false
112+ rebuild_quiz=false
113+ rebuild_hugo=true
114+ rebuild_terminal=false
115+ rebuild_cli=false
116+ ;;
117+ terminal)
118+ rebuild_corporate=false
119+ rebuild_quiz=false
120+ rebuild_hugo=false
121+ rebuild_terminal=true
122+ rebuild_cli=false
123+ ;;
124+ cli)
125+ rebuild_corporate=false
126+ rebuild_quiz=false
127+ rebuild_hugo=false
128+ rebuild_terminal=false
129+ rebuild_cli=true
130+ ;;
131+ all|*)
132+ rebuild_corporate=true
133+ rebuild_quiz=true
134+ rebuild_hugo=true
135+ rebuild_terminal=true
136+ rebuild_cli=true
137+ ;;
138+ esac
139+ fi
140+
141+ echo "rebuild_corporate=$rebuild_corporate" >> $GITHUB_OUTPUT
142+ echo "rebuild_quiz=$rebuild_quiz" >> $GITHUB_OUTPUT
143+ echo "rebuild_hugo=$rebuild_hugo" >> $GITHUB_OUTPUT
144+ echo "rebuild_terminal=$rebuild_terminal" >> $GITHUB_OUTPUT
145+ echo "rebuild_cli=$rebuild_cli" >> $GITHUB_OUTPUT
146+
147+ echo "🎯 Rebuild scope:"
148+ echo " Corporate: $rebuild_corporate"
149+ echo " Quiz: $rebuild_quiz"
150+ echo " Hugo: $rebuild_hugo"
151+ echo " Terminal: $rebuild_terminal"
152+ echo " CLI: $rebuild_cli"
153+
154+ build :
155+ runs-on : ubuntu-latest
156+ needs : determine-scope
157+ steps :
158+ - name : Checkout hub repository
159+ uses : actions/checkout@v4
160+ with :
161+ token : ${{ secrets.PAT_TOKEN }}
162+
163+ - name : Setup Hugo
164+ uses : peaceiris/actions-hugo@v2
165+ with :
166+ hugo-version : ' 0.110.0'
167+ extended : true
168+
169+ - name : Setup Pages
170+ id : pages
171+ uses : actions/configure-pages@v4
172+
173+ - name : Checkout hugo-templates
174+ uses : actions/checkout@v4
175+ with :
176+ repository : info-tech-io/hugo-templates
177+ token : ${{ secrets.PAT_TOKEN }}
178+ path : hugo-templates
179+
180+ - name : Prepare build directory
181+ run : |
182+ mkdir -p build-output
183+ cd hugo-templates
184+ npm install
185+
186+ - name : Build Corporate Site
187+ if : needs.determine-scope.outputs.rebuild_corporate == 'true'
188+ run : |
189+ echo "🏢 Building Corporate Site..."
190+
191+ # Checkout content
192+ git clone https://github.com/info-tech-io/info-tech.git content-corporate
193+
194+ # Build site
195+ cd hugo-templates
196+ chmod +x scripts/build.sh
197+ scripts/build.sh \
198+ --template corporate \
199+ --content ../content-corporate/docs/content \
200+ --base-url "https://info-tech-io.github.io" \
201+ --output ../build-output/corporate
202+
203+ # Move to root for GitHub Pages
204+ cd ..
205+ cp -r build-output/corporate/* build-output/
206+
207+ - name : Build Quiz Documentation
208+ if : needs.determine-scope.outputs.rebuild_quiz == 'true'
209+ run : |
210+ echo "🧩 Building Quiz Documentation..."
211+
212+ # Checkout content
213+ git clone https://github.com/info-tech-io/quiz.git content-quiz
214+
215+ # Build site
216+ cd hugo-templates
217+ scripts/build.sh \
218+ --template documentation \
219+ --content ../content-quiz/docs/content \
220+ --base-url "https://info-tech-io.github.io/quiz" \
221+ --output ../build-output/quiz
222+
223+ - name : Build Hugo Templates Documentation
224+ if : needs.determine-scope.outputs.rebuild_hugo == 'true'
225+ run : |
226+ echo "🔧 Building Hugo Templates Documentation..."
227+
228+ # Checkout content
229+ git clone https://github.com/info-tech-io/hugo-templates.git content-hugo-templates
230+
231+ # Build site
232+ cd hugo-templates
233+ scripts/build.sh \
234+ --template documentation \
235+ --content ../content-hugo-templates/docs/content \
236+ --base-url "https://info-tech-io.github.io/hugo" \
237+ --output ../build-output/hugo
238+
239+ - name : Build Web Terminal Documentation
240+ if : needs.determine-scope.outputs.rebuild_terminal == 'true'
241+ run : |
242+ echo "💻 Building Web Terminal Documentation..."
243+
244+ # Checkout content
245+ git clone https://github.com/info-tech-io/web-terminal.git content-web-terminal
246+
247+ # Build site
248+ cd hugo-templates
249+ scripts/build.sh \
250+ --template documentation \
251+ --content ../content-web-terminal/docs/content \
252+ --base-url "https://info-tech-io.github.io/terminal" \
253+ --output ../build-output/terminal
254+
255+ - name : Build CLI Documentation
256+ if : needs.determine-scope.outputs.rebuild_cli == 'true'
257+ run : |
258+ echo "⚙️ Building CLI Documentation..."
259+
260+ # Checkout content
261+ git clone https://github.com/info-tech-io/info-tech-cli.git content-cli
262+
263+ # Build site
264+ cd hugo-templates
265+ scripts/build.sh \
266+ --template documentation \
267+ --content ../content-cli/docs/content \
268+ --base-url "https://info-tech-io.github.io/cli" \
269+ --output ../build-output/cli
270+
271+ - name : Create site index
272+ run : |
273+ echo "📋 Creating site index..."
274+
275+ # Create index.html if corporate site wasn't built
276+ if [[ ! -f "build-output/index.html" ]]; then
277+ cat > build-output/index.html << 'EOF'
278+ <!DOCTYPE html>
279+ <html>
280+ <head>
281+ <meta charset="utf-8">
282+ <title>InfoTech.io - Open Source Educational Technology</title>
283+ <meta http-equiv="refresh" content="0; url=https://info-tech.io">
284+ <link rel="canonical" href="https://info-tech.io">
285+ </head>
286+ <body>
287+ <h1>InfoTech.io</h1>
288+ <p>Redirecting to <a href="https://info-tech.io">info-tech.io</a>...</p>
289+
290+ <h2>Available Sites:</h2>
291+ <ul>
292+ <li><a href="/quiz/">Quiz Engine Documentation</a></li>
293+ <li><a href="/hugo/">Hugo Templates Documentation</a></li>
294+ <li><a href="/terminal/">Web Terminal Documentation</a></li>
295+ <li><a href="/cli/">CLI Documentation</a></li>
296+ </ul>
297+ </body>
298+ </html>
299+ EOF
300+ fi
301+
302+ - name : Upload artifact
303+ uses : actions/upload-pages-artifact@v3
304+ with :
305+ path : build-output
306+
307+ deploy :
308+ environment :
309+ name : github-pages
310+ url : ${{ steps.deployment.outputs.page_url }}
311+ runs-on : ubuntu-latest
312+ needs : build
313+ steps :
314+ - name : Deploy to GitHub Pages
315+ id : deployment
316+ uses : actions/deploy-pages@v4
0 commit comments