Simplify trainer config (#329) #894
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Sphinx Doc to Pages | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'docs/sphinx_doc/**/*' | |
push: | |
branches: | |
- main | |
jobs: | |
pages: | |
timeout-minutes: 20 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.10'] | |
env: | |
OS: ${{ matrix.os }} | |
PYTHON: '3.10' | |
steps: | |
- 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 -q -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' |