Make the PDF cover a full A4 page #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build the OKF manual (Thai + English mdBook) and deploy to GitHub Pages. | |
| # Thai at the site root, English under /en/, plus an embedded example graph and PDFs. | |
| name: book | |
| on: | |
| push: | |
| branches: [main] | |
| paths: ["book/**", "book-en/**", "tools/**", "wiki/**", ".github/workflows/book.yml"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| MDBOOK_VERSION: "0.4.40" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install mdBook | |
| run: | | |
| curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \ | |
| | tar -xz -C /usr/local/bin | |
| - name: Build Thai book (site root) | |
| run: mdbook build book | |
| - name: Build English book | |
| run: mdbook build book-en | |
| - name: Assemble site (EN under /en, example graph) | |
| run: | | |
| python3 tools/okf-viz.py ./wiki --name "Self-OKF Wiki" | |
| cp wiki/viz.html book/book/viz-example.html | |
| mkdir -p book/book/en | |
| cp -r book-en/book/* book/book/en/ | |
| cp wiki/viz.html book/book/en/viz-example.html | |
| - name: Generate PDFs (best-effort) | |
| continue-on-error: true | |
| run: | | |
| # Thai fonts MUST be present on the runner, else Chrome falls back to a | |
| # font without Thai glyphs and the Thai PDF renders broken. fonts-thai-tlwg | |
| # guarantees Thai coverage; fonts-noto-* match the on-page font + emoji. | |
| sudo apt-get update -qq | |
| sudo apt-get install -y -qq fonts-thai-tlwg fonts-noto-core fonts-noto-color-emoji \ | |
| || sudo apt-get install -y -qq fonts-thai-tlwg | |
| sudo fc-cache -f >/dev/null 2>&1 || true | |
| CHROME="$(command -v google-chrome || command -v google-chrome-stable || command -v chromium-browser || command -v chromium || true)" | |
| # --virtual-time-budget lets the Google-Fonts web font + layout settle before printing. | |
| FLAGS="--headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage --no-pdf-header-footer --virtual-time-budget=20000 --run-all-compositor-stages-before-draw" | |
| if [ -n "$CHROME" ]; then | |
| "$CHROME" $FLAGS --print-to-pdf="$PWD/book/book/okf-manual-th.pdf" "file://$PWD/book/book/print.html" || true | |
| "$CHROME" $FLAGS --print-to-pdf="$PWD/book/book/en/okf-manual-en.pdf" "file://$PWD/book-en/book/print.html" || true | |
| else | |
| echo "No Chrome found — skipping PDF generation (the in-book print page still works)." | |
| fi | |
| - uses: actions/configure-pages@v5 | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: book/book | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - id: deployment | |
| uses: actions/deploy-pages@v4 |