Skip to content

Commit

Permalink
Add self-hosted docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Nov 28, 2024
1 parent 04e4968 commit 5545fc0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 18 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy Documentation

on:
push:
branches:
- master

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Python 3.12
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Cache virtualenv
id: venv-cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-3.12
restore-keys: |
venv-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-
venv-${{ runner.os }}-${{ github.job }}-
venv-${{ runner.os }}-
- name: Install Poetry
run: python -m pip install poetry
- name: Cache Poetry and pip
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: poetry-pip-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-pip-${{ runner.os }}-
- name: Install Dependencies with Poetry
run: poetry install --no-interaction --no-ansi
- name: Build Documentation
run: |
poetry run make build-docs
- name: Install AWS CLI
run: |
sudo apt update
sudo apt install -y awscli
- name: Configure AWS CLI for Cloudflare R2
run: |
aws configure set aws_access_key_id ${{ secrets.CF_R2_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.CF_R2_SECRET_ACCESS_KEY }}
aws configure set default.region us-east-1 # R2 uses us-east-1 by default
aws configure set default.output json
- name: Sync to Cloudflare R2
env:
CF_R2_ENDPOINT: ${{ secrets.CF_R2_ENDPOINT }}
CF_R2_BUCKET_NAME: ${{ secrets.CF_R2_BUCKET_NAME }}
run: |
aws s3 sync docs/build/en/html s3://$CF_R2_BUCKET_NAME/en/ \
--delete \
--acl public-read \
--endpoint-url $CF_R2_ENDPOINT
aws s3 sync docs/build/ru/html s3://$CF_R2_BUCKET_NAME/ru/ \
--delete \
--acl public-read \
--endpoint-url $CF_R2_ENDPOINT
17 changes: 0 additions & 17 deletions .readthedocs.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ translate: .venv
sphinx-intl update -p docs/build/gettext -l ru -d docs/source/locale


docs: translate
build-docs: translate
make -C docs/ -e BUILDDIR="build/en" html
make -C docs/ -e SPHINXOPTS="-D language='ru'" -e BUILDDIR="build/ru" html

docs: build-docs
python -m webbrowser -t "file://$(shell pwd)/docs/build/en/html/index.html"
python -m webbrowser -t "file://$(shell pwd)/docs/build/ru/html/index.html"
4 changes: 4 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinxcontrib.googleanalytics",
]

googleanalytics_id = "G-LKL5Q0MGWZ"
googleanalytics_enabled = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down

0 comments on commit 5545fc0

Please sign in to comment.