Skip to content
This repository was archived by the owner on Jun 25, 2026. It is now read-only.

Commit ae5cd3e

Browse files
authored
Merge pull request #8 from T-DAT-902-Homepedia/7-add-docker-container-and-github-workflow-automate-the-work-with-mdbook
Setup mdBook dev tools for docs writing
2 parents fbdf539 + 0af3893 commit ae5cd3e

9 files changed

Lines changed: 2759 additions & 0 deletions

File tree

.github/workflows/mdbook-ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy documentation to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'documentation/**'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Rust
27+
uses: actions-rust-lang/setup-rust-toolchain@v1
28+
29+
- name: Setup mdBook
30+
uses: peaceiris/actions-mdbook@v2
31+
with:
32+
mdbook-version: 'latest'
33+
34+
- name: Install mdbook-mermaid
35+
run: cargo install mdbook-mermaid
36+
37+
- name: Build book
38+
working-directory: ./documentation
39+
run: mdbook build
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: ./documentation/book
45+
46+
deploy:
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
runs-on: ubuntu-latest
51+
needs: build
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

Justfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
default:
2+
just --list
3+
4+
up ENV:
5+
#!/bin/bash
6+
if [ "{{ENV}}" = "doc" ]; then
7+
else
8+
echo "{{ENV}}: Accepted values are: 'doc'." >&2
9+
fi
10+
11+
down ENV:
12+
#!/bin/bash
13+
if [ "{{ENV}}" = "doc" ]; then
14+
docker compose -f docker/doc/compose.yml up --detach
15+
else
16+
echo "{{ENV}}: Accepted values are: 'doc'." >&2
17+
fi
18+
19+
logs ENV:
20+
#!/bin/bash
21+
if [ "{{ENV}}" = "doc" ]; then
22+
docker compose -f docker/{{ENV}}/compose.yml logs --follow
23+
else
24+
echo "{{ENV}}: Accepted values are: 'doc'." >&2
25+
fi
26+
27+

docker/doc/compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
mdbook:
3+
container_name: mdbook
4+
image: peaceiris/mdbook:v0.5.0-rust
5+
user: "${UID:-1000}:${GID:-1000}"
6+
working_dir: /book
7+
stdin_open: true
8+
tty: true
9+
ports:
10+
- 3000:3000
11+
- 3001:3001
12+
volumes:
13+
- ../../documentation:/book
14+
command: serve --hostname 0.0.0.0

documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

documentation/book.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[book]
2+
title = "Authentication Service"
3+
authors = ["Gabriel Lopez"]
4+
language = "en"
5+
6+
[preprocessor]
7+
8+
[preprocessor.mermaid]
9+
command = "mdbook-mermaid"
10+
11+
[output]
12+
13+
[output.html]
14+
additional-js = ["mermaid.min.js", "mermaid-init.js"]

documentation/mermaid-init.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
(() => {
6+
const darkThemes = ['ayu', 'navy', 'coal'];
7+
const lightThemes = ['light', 'rust'];
8+
9+
const classList = document.getElementsByTagName('html')[0].classList;
10+
11+
let lastThemeWasLight = true;
12+
for (const cssClass of classList) {
13+
if (darkThemes.includes(cssClass)) {
14+
lastThemeWasLight = false;
15+
break;
16+
}
17+
}
18+
19+
const theme = lastThemeWasLight ? 'default' : 'dark';
20+
mermaid.initialize({ startOnLoad: true, theme });
21+
22+
// Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page
23+
24+
for (const darkTheme of darkThemes) {
25+
document.getElementById(darkTheme).addEventListener('click', () => {
26+
if (lastThemeWasLight) {
27+
window.location.reload();
28+
}
29+
});
30+
}
31+
32+
for (const lightTheme of lightThemes) {
33+
document.getElementById(lightTheme).addEventListener('click', () => {
34+
if (!lastThemeWasLight) {
35+
window.location.reload();
36+
}
37+
});
38+
}
39+
})();

documentation/mermaid.min.js

Lines changed: 2609 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)