-
Notifications
You must be signed in to change notification settings - Fork 9
63 lines (58 loc) · 2.44 KB
/
gh_pages_doc.yml
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
name: Build and Deploy docs to GH pages
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches: ["master"]
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: 3.12 # Specify the Python version compatible with your environment
environment-file: docs/environment.yml # Use your environment.yml to install dependencies
activate-environment: readthedocs # Name from environment.yml
auto-activate-base: false
- run: |
sphinx-multiversion docs/source _build/html
- name: Create 'stable' version if deploying
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
run: |
if [ "$(git tag)" ]; then
latest_tag=$(git tag --sort=-v:refname | head -n 1)
echo "Latest tag is: $latest_tag"
cp -r _build/html/$latest_tag _build/html/stable
redirect_target="stable/index.html"
else
echo "No tags found. Using 'master' as fallback."
redirect_target="master/index.html"
fi
echo '<!DOCTYPE html>' > _build/html/index.html
echo '<html>' >> _build/html/index.html
echo '<head>' >> _build/html/index.html
echo ' <meta http-equiv="refresh" content="0; url='$redirect_target'">' >> _build/html/index.html
echo ' <title>Redirecting...</title>' >> _build/html/index.html
echo '</head>' >> _build/html/index.html
echo '<body>' >> _build/html/index.html
echo ' <p>If you are not redirected automatically, follow this <a href="'$redirect_target'">link to the documentation</a>.</p>' >> _build/html/index.html
echo '</body>' >> _build/html/index.html
echo '</html>' >> _build/html/index.html
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html