Skip to content

Commit 1aae615

Browse files
Automatically add exercise links to sections. (mainmatter#52)
We use an mdbook preprocessor to automatically generate links to the relevant exercise for each section. We remove all existing manual links and refactor the deploy process to push the rendered book to a branch.
1 parent 99591a7 commit 1aae615

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1967
-324
lines changed

.github/workflows/ci.yml

+31-11
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@ on:
99
- main
1010

1111
jobs:
12-
formatter:
12+
build:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
16-
- uses: dprint/[email protected]
17-
18-
check-links:
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
15+
- uses: actions/checkout@v4
16+
- uses: actions-rust-lang/setup-rust-toolchain@v1
17+
- name: Install plugin
18+
run: cargo install --path helpers/mdbook-exercise-linker
19+
- uses: taiki-e/install-action@v2
20+
with:
21+
tool: mdbook
2322
- name: Build book
2423
run: |
2524
cd book
26-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=.
27-
./mdbook build
25+
mdbook build
2826
- name: Link Checker
2927
uses: lycheeverse/lychee-action@v1
3028
with:
@@ -34,3 +32,25 @@ jobs:
3432
--require-https
3533
--no-progress
3634
book/book
35+
# Upload the book as an artifact
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: book
39+
path: book/book
40+
# Commit and push all changed files.
41+
# Must only affect files that are listed in "paths-ignore".
42+
- name: Git commit build artifacts
43+
# Only run on main branch push (e.g. pull request merge).
44+
if: github.event_name == 'push'
45+
run: |
46+
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
47+
git config --global user.email "[email protected]"
48+
git add --force book/book
49+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
50+
git push --set-upstream --force-with-lease origin deploy
51+
52+
formatter:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: dprint/[email protected]

0 commit comments

Comments
 (0)