6868 options :
6969 - dev
7070 - main
71+ # Target selection
72+ build_target :
73+ description : ' 📦 Build target (vol1, vol2, vol3, vol4, all)'
74+ required : true
75+ default : ' all'
76+ type : choice
77+ options :
78+ - all
79+ - vol1
80+ - vol2
81+ - vol3
82+ - vol4
7183 # Format & OS selection
7284 build_formats :
7385 description : ' 📦 Build formats (all, html, pdf, epub)'
@@ -191,39 +203,69 @@ jobs:
191203 build_epub : ${{ steps.config.outputs.build_epub }}
192204 build_linux : ${{ steps.config.outputs.build_linux }}
193205 build_windows : ${{ steps.config.outputs.build_windows }}
206+ build_target : ${{ steps.config.outputs.build_target }}
194207 container_registry : ${{ steps.config.outputs.container_registry }}
195208 container_tag : ${{ steps.config.outputs.container_tag }}
196209 target : ${{ steps.config.outputs.target }}
197210
198211 steps :
212+ - name : 📥 Checkout repository
213+ uses : actions/checkout@v6
214+ with :
215+ fetch-depth : 2
216+
199217 - name : 🎯 Determine build configuration
200218 id : config
201219 run : |
202220 echo "🎯 === BUILD CONFIGURATION ==="
203221
204222 # Determine what to build based on inputs (individual format flags)
205- if [ "${{ github.event_name }}" = "push" ]; then
206- # Auto-trigger: build Linux only. Windows validate-dev is temporarily
207- # disabled on push — the Windows container itself is still built by
208- # infra-container-windows.yml on its own schedule/path triggers.
209- # Re-enable by flipping BUILD_WINDOWS back to "true" below.
223+ if [ "${{ github.event_name }}" = "push" ] || [ "${{ github.event_name }}" = "pull_request" ]; then
210224 BUILD_HTML="true"
211225 BUILD_PDF="true"
212226 BUILD_EPUB="true"
213227 BUILD_LINUX="true"
214228 BUILD_WINDOWS="false"
215- TARGET="dev" # For push events, always target dev
216- echo "📊 Trigger: Automatic (dev branch push)"
217- echo "📊 HTML: $BUILD_HTML (mandatory)"
218- echo "📊 PDF: $BUILD_PDF (mandatory)"
219- echo "📊 EPUB: $BUILD_EPUB (mandatory)"
220- echo "📊 Linux: $BUILD_LINUX (mandatory)"
221- echo "📊 Windows: $BUILD_WINDOWS (temporarily disabled on dev push)"
222- echo "📊 Method: container-only"
223- echo "📊 Target: $TARGET"
229+ TARGET="dev"
230+
231+ # Selective auto-detection of modified volume paths
232+ CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
233+ echo "📝 Changed files: $CHANGED_FILES"
234+
235+ HAS_VOL1=false
236+ HAS_VOL2=false
237+ HAS_VOL3=false
238+ HAS_VOL4=false
239+ HAS_SHARED=false
240+
241+ while IFS= read -r file; do
242+ [ -z "$file" ] && continue
243+ if [[ "$file" =~ ^books/vol1/ ]]; then HAS_VOL1=true; fi
244+ if [[ "$file" =~ ^books/vol2/ ]]; then HAS_VOL2=true; fi
245+ if [[ "$file" =~ ^books/vol3/ ]]; then HAS_VOL3=true; fi
246+ if [[ "$file" =~ ^books/vol4/ ]]; then HAS_VOL4=true; fi
247+ if [[ "$file" =~ ^publishing/ || "$file" =~ ^shared/ || "$file" =~ ^\.github/ ]]; then HAS_SHARED=true; fi
248+ done <<< "$CHANGED_FILES"
249+
250+ if [ "$HAS_SHARED" = true ]; then
251+ BUILD_TARGET="all"
252+ elif [ "$HAS_VOL1" = true ] && [ "$HAS_VOL2" = false ] && [ "$HAS_VOL3" = false ] && [ "$HAS_VOL4" = false ]; then
253+ BUILD_TARGET="vol1"
254+ elif [ "$HAS_VOL2" = true ] && [ "$HAS_VOL1" = false ] && [ "$HAS_VOL3" = false ] && [ "$HAS_VOL4" = false ]; then
255+ BUILD_TARGET="vol2"
256+ elif [ "$HAS_VOL3" = true ] && [ "$HAS_VOL1" = false ] && [ "$HAS_VOL2" = false ] && [ "$HAS_VOL4" = false ]; then
257+ BUILD_TARGET="vol3"
258+ elif [ "$HAS_VOL4" = true ] && [ "$HAS_VOL1" = false ] && [ "$HAS_VOL2" = false ] && [ "$HAS_VOL3" = false ]; then
259+ BUILD_TARGET="vol4"
260+ else
261+ BUILD_TARGET="all"
262+ fi
263+
264+ echo "📊 Trigger: Automatic ($BUILD_TARGET detected)"
224265 else
225266 # Manual trigger: respect choices
226- echo "📊 Trigger: Manual workflow dispatch"
267+ BUILD_TARGET="${{ inputs.build_target || 'all' }}"
268+ echo "📊 Trigger: Manual workflow dispatch ($BUILD_TARGET)"
227269 BUILD_HTML="false"
228270 if [[ "${{ inputs.build_formats }}" == "all" || "${{ inputs.build_formats }}" == "html" ]]; then
229271 BUILD_HTML="true"
@@ -247,28 +289,25 @@ jobs:
247289 fi
248290
249291 TARGET="${{ inputs.target }}"
250-
251- echo "📊 Formats: ${{ inputs.build_formats }} (HTML: $BUILD_HTML, PDF: $BUILD_PDF)"
252- echo "📊 OS: ${{ inputs.build_os }} (Linux: $BUILD_LINUX, Windows: $BUILD_WINDOWS)"
253- echo "📊 Method: container-only"
254- echo "📊 Target: $TARGET"
255292 fi
256293
257294 # Container configuration
258295 CONTAINER_REGISTRY="${{ inputs.container_registry || 'ghcr.io' }}"
259296 CONTAINER_TAG="${{ inputs.container_tag || 'latest' }}"
260297
261298 echo "📊 Final Configuration:"
299+ echo " Target Volume: $BUILD_TARGET"
262300 echo " HTML: $BUILD_HTML"
263301 echo " PDF: $BUILD_PDF"
302+ echo " EPUB: $BUILD_EPUB"
264303 echo " Linux: $BUILD_LINUX"
265304 echo " Windows: $BUILD_WINDOWS"
266- echo " Method: container"
267305 echo " Registry: $CONTAINER_REGISTRY"
268306 echo " Tag: $CONTAINER_TAG"
269307 echo " Target: $TARGET"
270308
271- # Set outputs (individual format flags for matrix-driven approach)
309+ # Set outputs
310+ echo "build_target=$BUILD_TARGET" >> $GITHUB_OUTPUT
272311 echo "build_html=$BUILD_HTML" >> $GITHUB_OUTPUT
273312 echo "build_pdf=$BUILD_PDF" >> $GITHUB_OUTPUT
274313 echo "build_epub=$BUILD_EPUB" >> $GITHUB_OUTPUT
@@ -278,7 +317,6 @@ jobs:
278317 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
279318 echo "target=$TARGET" >> $GITHUB_OUTPUT
280319
281-
282320 # Step 4: Matrix-driven build calls (clean and simple!)
283321 build-container :
284322 name : ' 🐳 Container Build Matrix'
@@ -293,7 +331,7 @@ jobs:
293331 build_html : ${{ needs.build-config.outputs.build_html == 'true' }}
294332 build_pdf : ${{ needs.build-config.outputs.build_pdf == 'true' }}
295333 build_epub : ${{ needs.build-config.outputs.build_epub == 'true' }}
296- build_target : all
334+ build_target : ${{ needs.build-config.outputs.build_target }}
297335 target : ${{ needs.build-config.outputs.target }}
298336 container_registry : ${{ needs.build-config.outputs.container_registry }}
299337 container_tag : ${{ needs.build-config.outputs.container_tag }}
0 commit comments