Skip to content

Commit aa7e77a

Browse files
authored
feat: Auto publish docs to version "develop" (#269)
Auto publish docs to version "develop". Every time we merge a change to main, we will publish a new version of document on "develop" version. (Instead of 1.1.0, 1.2.0, etc. which are published only when we release.). All of our docs are kept in the branch "gh-pages". The branch is special as it doesn't contain any source code, only published docs. In the workflow, we publish the docs using two tools: mkdocs and mike. mkdocs generates a static website from ./doc into./site folder. mike runs on the top of mkdocs to generate a new version into another directory. The idea of mike is that we keep the older version of doc published and never touch it. When we release a version 1.2.0, mike will create a new folder named 1.2.0 and put the new version of mkdocs generated site there. All of these happens in the "gh-pages" branch. In this workflow, when we push to main branch, we will regenerate the special version "develop". This will replace the folder "develop" with the latest generated doc. (We also have the alias "latest" for the latest release version. This will be covered in the release workflow).
1 parent 41a6eb3 commit aa7e77a

File tree

5 files changed

+8496
-19887
lines changed

5 files changed

+8496
-19887
lines changed

.github/workflows/on-docs-change.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Auto publish docs to version "develop"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
- 'CHANGELOG.md'
10+
- 'mkdocs.yml'
11+
- '.github/workflows/on-docs-change.yml'
12+
13+
jobs:
14+
docs:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Set up Python
21+
uses: actions/[email protected]
22+
with:
23+
python-version: "3.8"
24+
- name: Install dependencies
25+
run: |
26+
pip install --upgrade pip
27+
pip install mike==1.1.2 mkdocs-material==8.0.5 mkdocs-git-revision-date-plugin==0.3.1
28+
- name: Setup doc deploy
29+
run: |
30+
git config --global user.name Docs deploy
31+
git config --global user.email [email protected]
32+
- name: Build docs website and (TODO) API reference
33+
run: |
34+
VERSION="develop"
35+
ALIAS="stage"
36+
mkdocs build
37+
mike deploy --push --update-aliases "$VERSION" "$ALIAS"
38+
- name: Deploy all docs
39+
uses: peaceiris/actions-gh-pages@v3
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
publish_dir: ./site
43+
keep_files: true
44+
destination_dir: develop/api

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ coverage
3232
.vscode
3333

3434
# Python virtual environments (for running mkdocs locally)
35-
venv
35+
venv
36+
37+
# Static documentation site generated by Mkdocs
38+
site

0 commit comments

Comments
 (0)