|
| 1 | +name: Build Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - doc-prod |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-doc: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v6 |
| 14 | + |
| 15 | + - name: Install uv |
| 16 | + uses: astral-sh/setup-uv@v7 |
| 17 | + with: |
| 18 | + python-version: "3.9" |
| 19 | + |
| 20 | + - name: Install system dependencies |
| 21 | + run: sudo apt-get update && sudo apt-get install rename |
| 22 | + |
| 23 | + - name: Install doc dependencies |
| 24 | + run: | |
| 25 | + cd doc |
| 26 | + uv venv |
| 27 | + source .venv/bin/activate |
| 28 | + uv pip install -r requirements.txt |
| 29 | +
|
| 30 | + - name: Install plotly in editable mode |
| 31 | + if: github.ref_name != 'doc-prod' |
| 32 | + run: | |
| 33 | + cd doc |
| 34 | + source .venv/bin/activate |
| 35 | + uv pip uninstall plotly |
| 36 | + uv pip install -e .. |
| 37 | +
|
| 38 | +
|
| 39 | + - name: Build HTML docs |
| 40 | + env: |
| 41 | + MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} |
| 42 | + run: | |
| 43 | + cd doc |
| 44 | + source .venv/bin/activate |
| 45 | + echo "${MAPBOX_TOKEN}" > python/.mapbox_token |
| 46 | + make -kj8 || make -kj8 |
| 47 | + curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/front-matter-ci.py > front-matter-ci.py |
| 48 | + curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/check-or-enforce-order.py > check-or-enforce-order.py |
| 49 | + python front-matter-ci.py build/html |
| 50 | + python check-or-enforce-order.py build/html |
| 51 | +
|
| 52 | + - name: Upload HTML docs artifact |
| 53 | + uses: actions/upload-artifact@v7 |
| 54 | + with: |
| 55 | + name: doc-html |
| 56 | + path: doc/build/html/ |
| 57 | + |
| 58 | + - name: Create GitHub App token |
| 59 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 60 | + uses: actions/create-github-app-token@v2 |
| 61 | + id: app-token |
| 62 | + with: |
| 63 | + app-id: ${{ vars.GRAPHING_LIBRARIES_CI_GHAPP_ID }} |
| 64 | + private-key: ${{ secrets.GRAPHING_LIBRARIES_CI_GHAPP_PRIVATE_KEY }} |
| 65 | + owner: ${{ github.repository_owner }} |
| 66 | + repositories: plotly.py-docs,graphing-library-docs |
| 67 | + |
| 68 | + - name: Checkout plotly.py-docs (built) |
| 69 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 70 | + uses: actions/checkout@v6 |
| 71 | + with: |
| 72 | + repository: plotly/plotly.py-docs |
| 73 | + ref: built |
| 74 | + token: ${{ steps.app-token.outputs.token }} |
| 75 | + path: plotly.py-docs-html |
| 76 | + |
| 77 | + - name: Deploy HTML docs |
| 78 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 79 | + run: | |
| 80 | + git config --global user.name plotlydocbot |
| 81 | + git config --global user.email accounts@plot.ly |
| 82 | + rm -rf plotly.py-docs-html/* |
| 83 | + cp -r doc/build/html/* plotly.py-docs-html/ |
| 84 | + cd plotly.py-docs-html |
| 85 | + git add . |
| 86 | + git commit -m "build of https://github.com/plotly/plotly.py/commit/${{ github.sha }}" || echo "No changes to commit" |
| 87 | + git push --force |
| 88 | +
|
| 89 | + - name: Checkout plotly.py-docs (built_ipynb) |
| 90 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 91 | + uses: actions/checkout@v6 |
| 92 | + with: |
| 93 | + repository: plotly/plotly.py-docs |
| 94 | + ref: built_ipynb |
| 95 | + token: ${{ steps.app-token.outputs.token }} |
| 96 | + path: plotly.py-docs-ipynb |
| 97 | + |
| 98 | + - name: Deploy notebooks |
| 99 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 100 | + run: | |
| 101 | + rm -rf plotly.py-docs-ipynb/* |
| 102 | + cp -r doc/build/ipynb/* plotly.py-docs-ipynb/ |
| 103 | + cd plotly.py-docs-ipynb |
| 104 | + git add . |
| 105 | + git commit -m "build of https://github.com/plotly/plotly.py/commit/${{ github.sha }}" || echo "No changes to commit" |
| 106 | + git push --force |
| 107 | +
|
| 108 | + - name: Checkout graphing-library-docs |
| 109 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 110 | + uses: actions/checkout@v6 |
| 111 | + with: |
| 112 | + repository: plotly/graphing-library-docs |
| 113 | + ref: master |
| 114 | + token: ${{ steps.app-token.outputs.token }} |
| 115 | + path: graphing-library-docs |
| 116 | + |
| 117 | + - name: Trigger downstream doc build |
| 118 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 119 | + run: | |
| 120 | + cd graphing-library-docs |
| 121 | + git commit --allow-empty -m "deploying https://github.com/plotly/plotly.py/commit/${{ github.sha }}" |
| 122 | + git push |
| 123 | +
|
| 124 | + - name: Build API docs |
| 125 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 126 | + run: | |
| 127 | + cd doc |
| 128 | + source .venv/bin/activate |
| 129 | + # For the API doc, we need to use the local version of plotly |
| 130 | + # since we are tweaking the source because of |
| 131 | + # graph_objs/graph_objects |
| 132 | + uv pip uninstall plotly |
| 133 | + uv pip install -e .. |
| 134 | + cd apidoc |
| 135 | + make html |
| 136 | +
|
| 137 | + - name: Checkout plotly.py-docs (gh-pages) |
| 138 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 139 | + uses: actions/checkout@v6 |
| 140 | + with: |
| 141 | + repository: plotly/plotly.py-docs |
| 142 | + ref: gh-pages |
| 143 | + token: ${{ steps.app-token.outputs.token }} |
| 144 | + path: plotly.py-docs-api |
| 145 | + |
| 146 | + - name: Deploy API docs |
| 147 | + if: github.ref_name == 'doc-prod' && github.event_name == 'push' |
| 148 | + run: | |
| 149 | + rm -rf plotly.py-docs-api/* |
| 150 | + cp -r doc/apidoc/_build/html/* plotly.py-docs-api/ |
| 151 | + touch plotly.py-docs-api/.nojekyll |
| 152 | + cd plotly.py-docs-api |
| 153 | + git add . |
| 154 | + git commit -m "build of https://github.com/plotly/plotly.py/commit/${{ github.sha }}" || echo "No changes to commit" |
| 155 | + git push --force |
0 commit comments