Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: GitHub Pages

on:
  push:
    branches:
      - master
    tags:
      - '*'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

permissions:
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: write # peaceiris/actions-gh-pages pushes to the gh-pages branch
    steps:
      - uses: actions/checkout@v7

      - name: Setup mdBook
        uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 # v2.0.0
        with:
          # mdbook-version: 'latest'
          mdbook-version: '0.5.3'

      - run: mdbook build book

      - name: Set output directory
        run: |
          OUTDIR=$(basename ${{ github.ref }})
          echo "OUTDIR=$OUTDIR" >> $GITHUB_ENV

      - name: Deploy stable
        uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
        if: startswith(github.ref, 'refs/tags/')
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./book/book
          # Preserve prior version subdirs at gh-pages root.
          keep_files: true

      - name: Deploy
        uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./book/book
          destination_dir: ./${{ env.OUTDIR }}