Skip to content

Commit 01e409e

Browse files
committed
Upd Deploy
1 parent ea481f1 commit 01e409e

File tree

1 file changed

+58
-31
lines changed

1 file changed

+58
-31
lines changed

.github/workflows/deploy.yml

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,66 @@
1-
name: Deploy
1+
name: Deploy mdBook
2+
23
on:
34
push:
4-
branches:
5-
- main
5+
branches: [main]
66
pull_request:
7-
types: [assigned, opened, synchronize, reopened]
7+
branches: [main]
88

99
jobs:
10+
test:
11+
name: Test build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Setup Rust
17+
uses: actions-rust-lang/setup-rust-toolchain@v1
18+
19+
- name: Install mdBook and plugins
20+
run: |
21+
cargo install mdbook
22+
cargo install mdbook-admonish
23+
cargo install mdbook-mermaid
24+
cargo install mdbook-linkcheck
25+
26+
- name: Build and test book
27+
run: |
28+
mdbook build
29+
mdbook test
30+
1031
deploy:
32+
name: Deploy to GitHub Pages
1133
runs-on: ubuntu-latest
34+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
35+
permissions:
36+
contents: write
37+
concurrency:
38+
group: ${{ github.workflow }}-${{ github.ref }}
1239
steps:
13-
- uses: actions/checkout@v2
14-
with:
15-
fetch-depth: 0
16-
- name: Install mdBook and plugins
17-
run: |
18-
mkdir mdbook
19-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.48/mdbook-v0.4.48-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
20-
curl -sSL https://github.com/tommilligan/mdbook-admonish/releases/download/v1.20.0/mdbook-admonish-v1.20.0-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
21-
curl -sSL https://github.com/badboy/mdbook-mermaid/releases/download/v0.15.0/mdbook-mermaid-v0.15.0-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
22-
cargo install mdbook-linkcheck2
23-
echo `pwd`/mdbook >> $GITHUB_PATH
24-
- name: Deploy GitHub Pages
25-
run: |
26-
# This assumes your book is in the root of your repository.
27-
# Just add a `cd` here if you need to change to another directory.
28-
mdbook build
29-
git worktree add gh-pages gh-pages
30-
git config user.name "Deploy from CI"
31-
git config user.email ""
32-
cd gh-pages
33-
# Delete the ref to avoid keeping history.
34-
git update-ref -d refs/heads/gh-pages
35-
rm -rf *
36-
mv ../book/* .
37-
git add .
38-
git commit -m "Deploy $GITHUB_SHA to gh-pages"
39-
git push --force
40+
- uses: actions/checkout@v5
41+
with:
42+
fetch-depth: 0
43+
44+
- name: Setup Rust
45+
uses: actions-rust-lang/setup-rust-toolchain@v1
46+
47+
- name: Install mdBook and plugins
48+
run: |
49+
cargo install mdbook
50+
cargo install mdbook-admonish
51+
cargo install mdbook-mermaid
52+
53+
- name: Build book
54+
run: mdbook build
55+
56+
- name: Setup Pages
57+
uses: actions/configure-pages@v5
58+
59+
- name: Upload artifact
60+
uses: actions/upload-pages-artifact@v4
61+
with:
62+
path: ./book
63+
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)