Skip to content

Commit 1b0b17f

Browse files
committed
[gh] Add GitHub Pages workflow for mdbook documentation
- Add new github_pages.yml workflow for publishing mdbook docs - Remove GitHub Pages deployment from docs.yml workflow - Clean up docs.yml to focus on Rust API documentation only - Use cargo xtask docs command to build mdbook documentation - Deploy static files from target/book to GitHub Pages - Separate concerns: docs.yml for API docs, github_pages.yml for site Signed-off-by: Miguel Osorio <[email protected]>
1 parent 33de888 commit 1b0b17f

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

.github/workflows/docs.yml

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,22 @@ on:
1010

1111
permissions:
1212
contents: read
13-
pages: write
14-
id-token: write
1513

1614
env:
1715
CARGO_TERM_COLOR: always
1816

1917
jobs:
2018
docs:
2119
name: Documentation
22-
# Only run this job on the main branch
23-
if: github.ref == 'refs/heads/main'
2420
runs-on: ubuntu-latest
25-
environment:
26-
name: github-pages
27-
url: ${{ steps.deployment.outputs.page_url }}
2821
steps:
2922
- uses: actions/checkout@v5
30-
23+
3124
- name: Install Rust toolchain
3225
uses: dtolnay/rust-toolchain@stable
3326
with:
3427
components: rust-docs
35-
28+
3629
- name: Cache cargo registry
3730
uses: actions/cache@v4
3831
with:
@@ -41,40 +34,12 @@ jobs:
4134
~/.cargo/git
4235
target
4336
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('**/Cargo.lock') }}
44-
37+
4538
- name: Build documentation
4639
run: cargo doc --all-features --no-deps --workspace
47-
48-
- name: Create index.html redirect for GitHub Pages
49-
run: |
50-
cat > target/doc/index.html << 'EOF'
51-
<!DOCTYPE html>
52-
<html>
53-
<head>
54-
<meta http-equiv="refresh" content="0; url=openprot/">
55-
<title>OpenProt Documentation</title>
56-
</head>
57-
<body>
58-
<p>Redirecting to <a href="openprot/">OpenProt Documentation</a>...</p>
59-
</body>
60-
</html>
61-
EOF
62-
40+
6341
- name: Check for broken links in docs
6442
run: |
6543
cargo install cargo-deadlinks
6644
cargo deadlinks --check-http
6745
continue-on-error: true
68-
69-
- name: Setup Pages
70-
uses: actions/configure-pages@v5
71-
72-
# Upload the 'github-pages' artifact
73-
- name: Upload artifact
74-
uses: actions/upload-pages-artifact@v4
75-
with:
76-
path: ./target/doc
77-
78-
- name: Deploy to GitHub Pages
79-
id: deployment
80-
uses: actions/deploy-pages@v4

.github/workflows/github_pages.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Licensed under the Apache-2.0 license
2+
3+
name: GitHub Pages
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
build-and-deploy:
20+
name: Build and Deploy to GitHub Pages
21+
runs-on: ubuntu-latest
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v5
28+
29+
- name: Install Rust toolchain
30+
uses: dtolnay/rust-toolchain@stable
31+
with:
32+
components: rust-docs
33+
34+
- name: Cache cargo registry
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.cargo/registry
39+
~/.cargo/git
40+
target
41+
key: ${{ runner.os }}-github-pages-cargo-${{ hashFiles('**/Cargo.lock') }}
42+
43+
- name: Install mdbook and mdbook-mermaid
44+
run: |
45+
cargo install mdbook --locked
46+
cargo install mdbook-mermaid --locked
47+
48+
- name: Build mdbook documentation
49+
run: cargo xtask docs
50+
51+
- name: Setup Pages
52+
uses: actions/configure-pages@v5
53+
54+
- name: Upload artifact
55+
uses: actions/upload-pages-artifact@v4
56+
with:
57+
path: ./target/book
58+
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)