File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Publish docs via GitHub Pages
2-
1+ name : Deploy MkDocs
32on :
43 push :
54 branches :
1211 - ' docs/**'
1312 - ' .github/workflows/deploy_mkdocs.yml'
1413
14+ permissions :
15+ contents : write
16+ pages : write
17+ id-token : write
18+
1519jobs :
1620 build :
1721 name : Deploy docs
2832 - name : Install dependencies
2933 run : |
3034 python -m pip install --upgrade pip
31- python -m pip install .["docs"]
35+ pip install -e .[docs]
36+
37+ - name : Configure Git
38+ run : |
39+ git config --global user.name "GitHub Actions"
40+ git config --global user.email "github-actions@users.noreply.github.com"
41+
42+ - name : Checkout gh-pages branch
43+ run : |
44+ git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages
45+ git checkout gh-pages
46+ git reset --hard # Clean working directory
3247
48+ - name : Save existing content
49+ run : |
50+ mkdir -p temp
51+ # Save important files/directories that should be preserved
52+ # Copy all the vx.x.x folders to preserve them
53+ for dir in $(find . -maxdepth 1 -type d -name 'vx.*'); do
54+ if [ -d "$dir" ]; then
55+ cp -r "$dir" temp/
56+ fi
57+ done
3358
34- - name : Deploy docs
35- run : mkdocs gh-deploy --force -f mkdocs.yml
59+ - name : Build documentation
60+ run : |
61+ git checkout main
62+ mkdocs build
63+
64+ - name : Deploy documentation
65+ run : |
66+ git checkout gh-pages
67+ # Remove all content except .git and temp directory
68+ find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'temp' -exec rm -rf {} +
69+ # Copy MkDocs output
70+ cp -r site/* .
71+ # Restore preserved content
72+ cp -r temp/* .
73+ # Clean up
74+ rm -rf site temp
75+ # Commit and push
76+ git add -A
77+ git commit -m "Deploy documentation updates" || echo "No changes to commit"
78+ git push origin gh-pages --force
You can’t perform that action at this time.
0 commit comments