Skip to content

Commit e8f783b

Browse files
committed
CI: install mdbook-toc; some cleanup
Changes: * Rename CI workflow + job * Upgrade mdbook (0.4.12 -> 0.4.14) * Separate variables * Add binaries to PATH
1 parent 9eadbc9 commit e8f783b

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

.github/workflows/cd.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: "Deploy to GitHub Pages"
22

3-
name: CI
4-
5-
# Controls when the action will run. Triggers the workflow on push or pull request
6-
# events but only for the master branch
73
on:
84
push:
9-
branches: [ master ]
10-
11-
5+
branches: [master]
126

7+
env:
8+
# Use fixed versions for now, replace with 'latest' to auto-use latest
9+
# Note: during build, there's a warning when using mdbook-toc compiled against an older mdbook version, should work though.
10+
MDBOOK_VERSION: "0.4.14"
11+
MDBOOK_TOC_VERSION: "0.7.0"
12+
MDBOOK_BIN: "/tmp/mdbook-bin"
1313

14-
15-
16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1714
jobs:
18-
# This workflow contains a single job called "build"
19-
build:
20-
# The type of runner that the job will run on
15+
build_and_deploy:
2116
runs-on: ubuntu-latest
2217

23-
# Steps represent a sequence of tasks that will be executed as part of the job
2418
steps:
25-
- name: Checkout 🛎️
26-
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
19+
# If using actions/checkout@v2, persist-credentials must be set to false in most cases for the deployment to work correctly.
20+
- name: "Checkout"
21+
uses: actions/checkout@v2
2722
with:
2823
persist-credentials: false
2924

30-
- name: Build book
25+
# Note: actions-rs/install@v0.1 was considered, but a full 'cargo install' is unnecessarily slow and the cache mechanism is not reliable
26+
# (error "Unable to download mdbook == 0.4.14 from the tool cache: Error: Unexpected HTTP response: 403")
27+
# So, directly pull the release from GitHub
28+
- name: "Install mdbook + mdbook-toc"
3129
run: |
32-
wget https://github.com/rust-lang/mdBook/releases/download/v0.4.12/mdbook-v0.4.12-x86_64-unknown-linux-gnu.tar.gz -O /tmp/mdbook.tar.gz
33-
/bin/tar -xvzf /tmp/mdbook.tar.gz -C /tmp
34-
/tmp/mdbook build
30+
wget https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/mdbook.tar.gz
31+
wget https://github.com/badboy/mdbook-toc/releases/download/${MDBOOK_TOC_VERSION}/mdbook-toc-${MDBOOK_TOC_VERSION}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/mdbook-toc.tar.gz
3532
33+
mkdir ${MDBOOK_BIN}
34+
echo ${MDBOOK_BIN} >> $GITHUB_PATH
35+
tar -xvzf /tmp/mdbook.tar.gz -C ${MDBOOK_BIN}
36+
tar -xvzf /tmp/mdbook-toc.tar.gz -C ${MDBOOK_BIN}
37+
38+
- name: "Build book"
39+
run: mdbook build
3640

37-
- name: Deploy 🚀
41+
- name: "Deploy"
3842
uses: JamesIves/github-pages-deploy-action@releases/v3
3943
with:
4044
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)