-
Notifications
You must be signed in to change notification settings - Fork 2
166 lines (141 loc) · 5.22 KB
/
deploy-mdbook.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Deploy mdBook Site to Pages
on:
push:
branches:
- "*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
id-token: write
pages: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build-deps:
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin
~/.cargo/git
~/.cargo/registry
target
key: ${{ runner.os }}-${{ runner.arch }}-cargo-deps
- name: Check for existing binaries
id: check-binaries
run: |
if [ -f ~/.cargo/bin/mdbook ] && \
[ -f ~/.cargo/bin/mdbook-admonish ] && \
[ -f ~/.cargo/bin/mdbook-footnote ] && \
[ -f ~/.cargo/bin/mdbook-graphviz ] && \
[ -f ~/.cargo/bin/mdbook-mermaid ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "All mdbook binaries found, will skip build"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Some mdbook binaries missing, will build"
fi
- name: Build all mdbook components
if: steps.check-binaries.outputs.exists != 'true'
run: |
mkdir -p target
cargo install mdbook --target-dir target
cargo install mdbook-admonish --target-dir target
cargo install mdbook-footnote --target-dir target
cargo install mdbook-graphviz --target-dir target
cargo install mdbook-mermaid --target-dir target
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: mdbook-binaries
path: |
~/.cargo/bin/mdbook
~/.cargo/bin/mdbook-admonish
~/.cargo/bin/mdbook-footnote
~/.cargo/bin/mdbook-graphviz
~/.cargo/bin/mdbook-mermaid
retention-days: 1
deploy-mdbook:
needs: build-deps
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Install System Dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends graphviz
- name: Download mdbook binaries
uses: actions/download-artifact@v4
with:
name: mdbook-binaries
path: /usr/local/bin
- name: Make binaries executable
run: |
sudo chmod +x /usr/local/bin/mdbook
sudo chmod +x /usr/local/bin/mdbook-admonish
sudo chmod +x /usr/local/bin/mdbook-footnote
sudo chmod +x /usr/local/bin/mdbook-graphviz
sudo chmod +x /usr/local/bin/mdbook-mermaid
- name: Prepare Assets Directories
run: mkdir -p src/fonts src/assets theme
- name: Setup Catppuccin Theme
run: |
# Create theme directory
mkdir -p theme
# Download latest Catppuccin theme
curl -sSfL -o theme/catppuccin.css \
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin.css
# Download Catppuccin admonish theme
curl -sSfL -o theme/catppuccin-admonish.css \
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin-admonish.css
# Download default theme's index.hbs for customization
curl -sSfL -o theme/index.hbs \
https://raw.githubusercontent.com/rust-lang/mdBook/master/src/theme/index.hbs
# Update index.hbs theme options
sed -i 's/Light/Latte/; s/Rust/Frappé/; s/Coal/Macchiato/; s/Navy/Mocha/; /Ayu/d' theme/index.hbs
- name: Download Additional Assets
run: |
# Devicon Fonts and CSS
curl -sSf \
-o devicon.min.css \
https://raw.githubusercontent.com/devicons/devicon/master/devicon.min.css
curl -sSf \
-o src/fonts/devicon.eot \
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.eot
curl -sSf \
-o src/fonts/devicon.svg \
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.svg
curl -sSf \
-o src/fonts/devicon.ttf \
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.ttf
curl -sSf \
-o src/fonts/devicon.woff \
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.woff
# WhichLang Assets
curl -sSf \
-o src/assets/whichlang.css \
https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/src/whichlang.css
curl -sSf \
-o src/assets/whichlang.js \
https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/dist/whichlang.js
- name: Build the mdBook Site
run: mdbook build
- name: Turn off Jekyll
run: touch book/.nojekyll
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
if: ${{ github.ref == 'refs/heads/main' }}