Using github actions to publish documentation

前端 未结 2 1404
深忆病人
深忆病人 2021-01-03 04:46

What I considered:

  • github offers github pages to host documentation in either a folder on my master branch or a dedicated gh-pages br
相关标签:
2条回答
  • 2021-01-03 05:01

    In the case of managing sphinx using pip (requirements.txt), pipenv, or poetry, we can deploy our documentation to GitHub Pages as follows. For also other Python-based Static Site Generators like pelican and MkDocs, the workflow works as same. Here is a simple example of MkDocs. We just add the workflow as .github/workflows/gh-pages.yml

    For more options, see the latest README: peaceiris/actions-gh-pages: GitHub Actions for GitHub Pages

    0 讨论(0)
  • 2021-01-03 05:03

    I got it to work, but there is no dedicated action to build and host sphinx docs on either github pages or readthedocs as of yet, so as far as I am concerned there is quite a bit left to be desired here.

    This is my current release_sphinx job that uses the deploy-action-for-github-pages action and uploads to github-pages:

    release_sphinx:
      needs: [build]
      runs-on: ubuntu-latest
      container:
        image: python:3.6
        volumes:
          - dist:dist
          - public:public
      steps:
    
        # check out sources that will be used for autodocs, plus readme
        - uses: actions/checkout@v1
    
        # download wheel that was build and uploaded in the build step
        - uses: actions/download-artifact@v1
          with:
            name: distributions
            path: dist
    
        # didn't need to change anything here, but had to add sphinx.ext.githubpages
        # to my conf.py extensions list. that fixes the broken uploads
        - name: Building documentation
          run: |
            pip install dist/*.whl
            pip install sphinx Pallets-Sphinx-Themes
            sphinx-apidoc --no-toc --module-first -o docs/autodoc src/stenotype
            sphinx-build docs public -b dirhtml
    
        # still need to build and set the PAT to get a rebuild on the pages job,
        # apart from that quite clean and nice 
        - name: github pages deploy
          uses: peaceiris/actions-gh-pages@v2.3.1
          env:
            PERSONAL_TOKEN: ${{ secrets.PAT }}
            PUBLISH_BRANCH: gh-pages
            PUBLISH_DIR: public
    
        # since gh-pages has a history, this step might no longer be necessary.
        - uses: actions/upload-artifact@v1
          with:
            name: documentation
            path: public
    

    Shoutout to the deploy action's maintainer, who resolved the upload problem within 8 minutes of me posting it as an issue.

    0 讨论(0)
提交回复
热议问题