@@ -7,14 +7,17 @@ name: Deploy
77on :
88 # Runs on pushes targeting the default branch
99 push :
10- branches : ["main"]
10+ branches :
11+ - main
12+ - ' ss*'
13+ - ' ws*'
1114
1215 # Allows you to run this workflow manually from the Actions tab
1316 workflow_dispatch :
1417
1518# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1619permissions :
17- contents : read
20+ contents : write
1821 pages : write
1922 id-token : write
2023
@@ -25,13 +28,15 @@ concurrency:
2528 cancel-in-progress : false
2629
2730jobs :
28- # Build job
29- build :
31+ build-and-deploy :
3032 runs-on : ubuntu-latest
3133 env :
3234 MDBOOK_VERSION : 0.4.37
3335 steps :
36+ # get the source code
3437 - uses : actions/checkout@v4
38+
39+ # install mdBook and preprocessors
3540 - name : Install mdBook
3641 run : |
3742 curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
@@ -44,26 +49,30 @@ jobs:
4449 cargo install mdbook-katex --locked --version 0.6.0
4550 cargo install mdbook-numeq --locked --version 0.3.0
4651 cargo install --git https://github.com/xmiaocat/mdbook-chapter-zero#e50441d
47- cargo install mdbook-shiftinclude --locked --version 0.1.0
48- - name : Setup Pages
49- id : pages
50- uses : actions/configure-pages@v4
52+
53+ # build the book
5154 - name : Build with mdBook
52- run : |
53- mdbook build
54- - name : Upload artifact
55- uses : actions/upload-pages-artifact@v3
55+ run : mdbook build
56+
57+ # deploy main branch
58+ - name : Deploy main branch
59+ if : github.ref_name == 'main'
60+ uses : JamesIves/github-pages-deploy-action@v4
5661 with :
57- path : ./book
62+ branch : gh-pages
63+ folder : book
64+ clean : true
65+ clean-exclude : |
66+ ss*
67+ ws*
68+
69+ # deploy archive branche
70+ - name : Deploy archive branches
71+ if : github.ref_name != 'main'
72+ uses : JamesIves/github-pages-deploy-action@v4
73+ with :
74+ branch : gh-pages
75+ folder : book
76+ target-folder : ${{ github.ref_name }}
77+ clean : true
5878
59- # Deployment job
60- deploy :
61- environment :
62- name : github-pages
63- url : ${{ steps.deployment.outputs.page_url }}
64- runs-on : ubuntu-latest
65- needs : build
66- steps :
67- - name : Deploy to GitHub Pages
68- id : deployment
69- uses : actions/deploy-pages@v4
0 commit comments