Debug GitHub Pages deployment structure #34
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
| # Source: https://github.com/rust-lang/mdBook/wiki/Automated-Deployment%3A-GitHub-Actions#GitHub-Pages-Deploy | |
| name: Deploy Documentation and Demo | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'docs/**' | |
| - 'demo/**' | |
| - '.github/workflows/deploy-books.yaml' | |
| workflow_dispatch: | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: 'demo/package-lock.json' | |
| - name: Install demo dependencies | |
| run: | | |
| cd demo | |
| npm ci | |
| - name: Build demo | |
| run: | | |
| cd demo | |
| npm run build | |
| - name: Install latest mdbook | |
| run: | | |
| tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') | |
| url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" | |
| mkdir mdbook | |
| curl -sSL $url | tar -xz --directory=./mdbook | |
| echo `pwd`/mdbook >> $GITHUB_PATH | |
| - name: Build documentation | |
| run: | | |
| cd docs | |
| mdbook build | |
| - name: Copy demo to docs | |
| run: | | |
| # Copy demo build to docs/book/demo for serving | |
| mkdir -p docs/book/demo | |
| cp -r demo/build/* docs/book/demo/ | |
| # Verify the structure | |
| echo "Documentation files:" | |
| ls -la docs/book/ | |
| echo "Demo files:" | |
| ls -la docs/book/demo/ | |
| # Ensure demo doesn't overwrite the main index.html | |
| echo "Demo copied to /demo/ subdirectory" | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'docs/book' | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 |