|
1 | | -# Workflow for building and deploying a mdBook site to GitHub Pages |
2 | | -# |
3 | | -# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html |
| 1 | +# Workflow for building and deploying a mdBook site to GitHub Pages. |
| 2 | +# Publishes to the gh-pages branch so PR previews (pr-<number>/) from |
| 3 | +# mdbook-pr-preview.yml are served from the same branch. Set Pages source |
| 4 | +# to "Deploy from a branch" → gh-pages, folder / (root). |
4 | 5 | # |
| 6 | +# See: https://rust-lang.github.io/mdBook/index.html |
5 | 7 | name: Deploy mdBook site to Pages |
6 | 8 |
|
7 | 9 | on: |
|
12 | 14 | # Allows you to run this workflow manually from the Actions tab |
13 | 15 | workflow_dispatch: |
14 | 16 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 17 | +# Push to gh-pages so PR previews (mdbook-pr-preview) are served from the same branch. |
| 18 | +# Repository Settings → Pages → Source: Deploy from a branch → gh-pages / (root). |
16 | 19 | permissions: |
17 | | - contents: read |
18 | | - pages: write |
19 | | - id-token: write |
| 20 | + contents: write |
20 | 21 |
|
21 | | -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
22 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
23 | 22 | concurrency: |
24 | 23 | group: "pages" |
25 | 24 | cancel-in-progress: false |
26 | 25 |
|
27 | 26 | jobs: |
28 | | - # Build job |
29 | | - build: |
| 27 | + build-and-deploy: |
30 | 28 | runs-on: ubuntu-latest |
31 | 29 | env: |
32 | 30 | CARGO_HOME: ${{ github.workspace }}/.cargo |
@@ -69,31 +67,17 @@ jobs: |
69 | 67 | REPO_ROOT: ${{ github.workspace }} |
70 | 68 | - name: Add Cargo bin to PATH |
71 | 69 | run: echo "${CARGO_HOME}/bin" >> "$GITHUB_PATH" |
72 | | - - name: Setup Pages |
73 | | - if: ${{ !env.ACT }} |
74 | | - id: pages |
75 | | - uses: actions/configure-pages@v5 |
76 | 70 | - name: Build with mdBook |
77 | 71 | run: ${{ env.CARGO_HOME }}/bin/mdbook build |
78 | | - - name: Upload artifact |
| 72 | + - name: Deploy to gh-pages (root) |
79 | 73 | if: ${{ !env.ACT }} |
80 | | - uses: actions/upload-pages-artifact@v3 |
| 74 | + uses: peaceiris/actions-gh-pages@v4 |
81 | 75 | with: |
82 | | - path: ./book |
| 76 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + publish_branch: gh-pages |
| 78 | + publish_dir: ./book |
| 79 | + keep_files: true |
83 | 80 | - name: Confirm local act build |
84 | 81 | if: ${{ env.ACT }} |
85 | 82 | run: | |
86 | | - echo "Local act run: mdBook build completed; skipping Pages upload/deploy steps." |
87 | | -
|
88 | | - # Deployment job |
89 | | - deploy: |
90 | | - if: ${{ !github.event.act }} |
91 | | - environment: |
92 | | - name: github-pages |
93 | | - url: ${{ steps.deployment.outputs.page_url }} |
94 | | - runs-on: ubuntu-latest |
95 | | - needs: build |
96 | | - steps: |
97 | | - - name: Deploy to GitHub Pages |
98 | | - id: deployment |
99 | | - uses: actions/deploy-pages@v4 |
| 83 | + echo "Local act run: mdBook build completed; skipping gh-pages deploy." |
0 commit comments