|
| 1 | + |
| 2 | +name: Docs CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout Source |
| 14 | + uses: actions/checkout@v2 |
| 15 | + with: |
| 16 | + # require all of history to see all tagged versions' docs |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v2 |
| 21 | + with: |
| 22 | + python-version: "3.7" |
| 23 | + |
| 24 | + - name: Install Packages |
| 25 | + # Can delete this if you don't use graphviz in your docs |
| 26 | + run: sudo apt-get install graphviz |
| 27 | + |
| 28 | + - name: Install Python Dependencies |
| 29 | + run: | |
| 30 | + pip install pipenv |
| 31 | + pipenv install --dev --deploy --python $(which python) && pipenv graph |
| 32 | +
|
| 33 | + - name: Deploy index |
| 34 | + # We pin to the SHA, not the tag, for security reasons. |
| 35 | + # https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions |
| 36 | + uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 |
| 37 | + with: |
| 38 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + publish_dir: .github/pages |
| 40 | + keep_files: true |
| 41 | + |
| 42 | + - name: Checkout gh-pages |
| 43 | + # As we already did a deploy of gh-pages above, it is guaranteed to be there |
| 44 | + # so check it out so we can selectively build docs below |
| 45 | + uses: actions/checkout@v2 |
| 46 | + with: |
| 47 | + ref: gh-pages |
| 48 | + path: build/html |
| 49 | + |
| 50 | + - name: Maybe use sphinx-multiversion |
| 51 | + # If we are building master or a tag we will publish |
| 52 | + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') |
| 53 | + # So use the args we normally pass to sphinx-build, but run sphinx-multiversion |
| 54 | + run: mv $(pipenv --venv)/bin/sphinx-multiversion $(pipenv --venv)/bin/sphinx-build |
| 55 | + |
| 56 | + - name: Build Docs |
| 57 | + run: pipenv run docs |
| 58 | + |
| 59 | + - name: Publish Docs to gh-pages |
| 60 | + # Only master and tags are published |
| 61 | + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') |
| 62 | + # We pin to the SHA, not the tag, for security reasons. |
| 63 | + # https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions |
| 64 | + uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 |
| 65 | + with: |
| 66 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + publish_dir: build/html |
| 68 | + keep_files: true |
| 69 | + |
0 commit comments