From 5d3aace45d898a6dd91d12b5ba2428dff317af1b Mon Sep 17 00:00:00 2001 From: tengxianglin Date: Mon, 1 Jul 2024 11:01:43 +0800 Subject: [PATCH] Update API Web Automation --- .github/workflows/web_update.yml | 55 ++++++++++++++++++++++++++++++++ api.sh | 3 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/web_update.yml diff --git a/.github/workflows/web_update.yml b/.github/workflows/web_update.yml new file mode 100644 index 0000000..330a000 --- /dev/null +++ b/.github/workflows/web_update.yml @@ -0,0 +1,55 @@ +name: API Auto Update # The name of the workflow indicates its purpose to automatically update the API documentation. + +on: # Defines the events that trigger the workflow. + push: + branches: ["main"] + workflow_dispatch: # This allows the workflow to be manually triggered. + +permissions: + contents: write + pages: write + id-token: write + +concurrency: + group: "pages" + +jobs: + deploy: # Defines a job called 'deploy'. + runs-on: ubuntu-latest # Specifies the virtual environment where the job will run. + + steps: + - name: Checkout # Step to checkout the repository's code. + uses: actions/checkout@v4 # Uses the actions/checkout action to access the repository code. + + - name: Configure GitHub Pages + uses: actions/configure-pages@v5 + + - name: Cache pip # Step to cache pip packages. + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies # Step to install dependencies. + run: | + pip install quairkit sphinx_immaterial + + - name: Generate Sphinx Documentation for API Documentation # Step to generate Sphinx documentation. + run: | + python docs/update_quairkit_rst.py + sphinx-build -b html docs/sphinx_src docs/api + + - name: Upload artifact # Step to upload the built site as an artifact. + uses: actions/upload-pages-artifact@v3 + with: + path: docs/api + + - name: Deploy to GitHub Pages # Step to deploy to GitHub Pages. + id: deployment + uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages # Specifies the branch to deploy to. + github_token: ${{ secrets.GITHUB_TOKEN }} # Authenticates using a GitHub Token. + publish_dir: ./docs/api # Specifies the directory to deploy. \ No newline at end of file diff --git a/api.sh b/api.sh index de342fc..6ccdacf 100644 --- a/api.sh +++ b/api.sh @@ -5,7 +5,8 @@ rm -rf docs/api/html rm -rf docs/api/sphinx_src # Step 1: 安装 Sphinx 和 sphinx_material(如果尚未安装) -pip install sphinx_material +pip show quairkit > /dev/null 2>&1 || pip install quairkit +pip show sphinx_immaterial > /dev/null 2>&1 || pip install sphinx_immaterial # Step 2: 生成所有必要的 rst 和 conf.py 文件 python docs/update_quairkit_rst.py