Repository navigation
89 lines (87 loc) · 2.61 KB
/
Copy pathsphinx-doc.yaml
File metadata and controls
89 lines (87 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Deploy Sphinx Doc to Pages
on:
pull_request:
types: [opened, synchronize]
paths:
- 'docs/sphinx_doc/**/*'
push:
branches:
- main
jobs:
pages:
timeout-minutes: 60
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.12']
env:
OS: ${{ matrix.os }}
PYTHON: '3.12'
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
docker system prune -af
- name: Checkout PR branch
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Checkout main branch
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
pip install -e .[doc]
- id: build
name: Build Documentation
run: |
cd docs/sphinx_doc
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
./build_doc.sh
else
BRANCH_NAME=$(git branch --show-current)
./build_doc.sh --branch "$BRANCH_NAME"
fi
- name: Add redirect index.html to main version
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
BRANCH_NAME="main"
else
BRANCH_NAME=$(git branch --show-current)
fi
REDIRECT_PATH="docs/sphinx_doc/build/html/index.html"
MAIN_INDEX="en/${BRANCH_NAME}/index.html"
cat > $REDIRECT_PATH <<EOF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=$MAIN_INDEX" />
<script>window.location.href = "$MAIN_INDEX";</script>
<title>Redirecting...</title>
</head>
<body>
<p>Redirecting to <a href="$MAIN_INDEX">$MAIN_INDEX</a></p>
</body>
</html>
EOF
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: SphinxDoc
path: 'docs/sphinx_doc/build'
- uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: 'docs/sphinx_doc/build/html'