我有一个项目,有一个关联的 github 页面,位于(比如说):
https://myorg.github.io/my_repo_name
我还有 python 模块的文档。 我希望也将文档部署到
docs
路径下的 github 页面,如下所示:
https://myorg.github.io/my_repo_name/docs
就其价值而言,该网站是使用 mystmd 构建的,并且文档是使用 sphinx 自动生成的。
目录结构在站点的根目录中包含
_build
目录,在子文件夹中包含 _build
文件夹,docs/
用于文档(见下文)。
是否可以对 github 页面进行两次单独的部署(一个部署到标准 url,一个部署到子路径)来完成此任务?
谢谢!
这是一个粗略的目录结构:
.
├── my_module
│ ├── __init__.py
│ ├── thing1.py
│ ├── thing2.py
| ...
├── _build
│ ├── html
│ │ ├── ...
│ │ ├── 8122.thebe-core.min
│ │ ├── ...
│ │ ├── index.html
│ │ ├── intro.html
│ │ ├── ...
| ...
├── docs
│ ├── _build
│ │ ├── ...
│ │ └── html
│ │ ├── index.html
│ │ | ...
按照@BenjaminW的建议,我只是将Sphinx文档移动到MyST文档的子文件夹中。 我通过 github 操作来管理此操作(对 myst 生成的操作进行编辑)。
关键是从初始工作流程中删除工件上传,然后用一些 Linux 命令替换它,以将所有内容移动到
_site
目录并将 _site
目录作为工件上传。 即
- name: Copy builds to site-directory
run: |
mv _build/html _site
mv docs/_build/html _site/docs
mkdir _site/nb
mv nb/public _site/nb/public
- name: Upload Site Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
这是完整的文件:
# This file was created by editing the file created by `myst init --gh-pages`
name: MyST and Sphinx GitHub Pages Deploy
on:
push:
branches: [main]
env:
# `BASE_URL` determines the website is served from, including CSS & JS assets
# You may need to change this to `BASE_URL: ''`
BASE_URL: /${{ github.event.repository.name }}
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install MyST Markdown
run: npm install -g mystmd
- name: Build MyST HTML Assets
run: myst build --html
- name: Install Sphinx and Dependencies
run: |
pip install sphinx sphinx-autodoc2 furo myst_parser
- name: Sphinx Build HTML
run: |
(cd docs && make html)
- name: Copy builds to site-directory
run: |
mv _build/html _site
mv docs/_build/html _site/docs
mkdir _site/nb
mv nb/public _site/nb/public
- name: Upload Site Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4