Skip to content

Commit

Permalink
chore: update deploy docs action
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 14, 2024
1 parent 6741f5d commit 347cc2e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 53 deletions.
60 changes: 32 additions & 28 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
name: Publish docs

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

on:
push:
branches:
- main
tags:
- "1.*"
paths-ignore:
- ".github/*"
- "tests/*"

env:
VERSION_PATH: dev

jobs:
publish:
build:
runs-on: ubuntu-latest

strategy:
matrix:
language: [ "en", "zh" ]

steps:
- name: update VERSION_PATH
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: echo VERSION_PATH=v$(echo $GITHUB_REF | cut -d / -f 3 | cut -d . -f 1) >> $GITHUB_ENV

- uses: actions/checkout@v3

- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand All @@ -44,14 +38,24 @@ jobs:
run: pip install .

- name: sphinx build
run: make build-docs -e lang=${{ matrix.language }}
env:
REF_NAME: ${{ github.ref_name }}
REF_TYPE: ${{ github.ref_type }}
REPOSITORY: ${{ github.repository }}

- name: deploy
uses: JamesIves/github-pages-deploy-action@v4
run: |
make build-docs -e lang=en
make build-docs -e lang=zh
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
folder: build/${{ matrix.language }}
target-folder: ${{ matrix.language }}/${{ env.VERSION_PATH }}/
path: public

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
lang=en

dev-docs:
sphinx-build docs public/${lang}/dev -D language=${lang} -b dirhtml -a
sphinx-build docs public/${lang} -D language=${lang} -b dirhtml -a


build-docs:
@sphinx-build docs build/${lang} -D language=${lang} -b dirhtml
@rm build/${lang}/.buildinfo
@rm -r build/${lang}/.doctrees
@sphinx-build docs public/${lang} -D language=${lang} -b dirhtml
@rm public/${lang}/.buildinfo
@rm -r public/${lang}/.doctrees


clean-docs:
Expand Down
23 changes: 6 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,9 @@
html_favicon = "_static/icon.svg"

html_theme_options = {
"accent_color": "blue",
"light_logo": "_static/light-logo.svg",
"dark_logo": "_static/dark-logo.svg",
"light_css_variables": {
"--sy-rc-theme": "62,127,203",
},
"dark_css_variables": {
"--sy-rc-theme": "102,173,255",
},
"twitter_site": "authlib",
"twitter_creator": "lepture",
"twitter_url": "https://twitter.com/authlib",
Expand Down Expand Up @@ -80,27 +75,21 @@
]
}

html_baseurl = "https://jose.authlib.org/en/dev/"
html_baseurl = "https://jose.authlib.org/en/"
html_context = {
"source_type": "github",
"source_user": "authlib",
"source_repo": "joserfc",
"source_docs_path": "/docs/",
}


def setup(app):
import os
global language, html_baseurl

language = app.config.language
ref_name = os.getenv("REF_NAME")
if ref_name and ref_name.startswith("1."):
version_path = "v1"
else:
version_path = "dev"

html_baseurl = f"https://jose.authlib.org/{language}/{version_path}/"
html_baseurl = f"https://jose.authlib.org/{language}/"
html_context["languages"] = [
("English", f"https://jose.authlib.org/en/{version_path}/%s/", "en"),
("简体中文", f"https://jose.authlib.org/zh/{version_path}/%s/", "zh"),
("English", f"https://jose.authlib.org/en/%s/", "en"),
("简体中文", f"https://jose.authlib.org/zh/%s/", "zh"),
]
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting to https://jose.authlib.org/en/</title>
<meta http-equiv="refresh" content="0; URL=https://jose.authlib.org/en/">
<link rel="canonical" href="https://jose.authlib.org/en/">
6 changes: 3 additions & 3 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx==6.2.1
sphinx-design==0.4.1
sphinx-copybutton==0.5.2
Sphinx
sphinx-design
sphinx-copybutton
shibuya
2 changes: 1 addition & 1 deletion serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
app.watch("docs/*.rst", shell("make dev-docs"), delay=2)
app.watch("docs/*/*.rst", shell("make dev-docs"), delay=2)
app.watch("docs/locales/zh/LC_MESSAGES/*.po", shell("make dev-docs -e lang=zh"), delay=2)
app.serve(root="build")
app.serve(root="public")

0 comments on commit 347cc2e

Please sign in to comment.