Skip to content

Commit 600f865

Browse files
authored
Merge pull request #5541 from plotly/migrate-to-gh-actions
Migrate docs build to GitHub Actions
2 parents 10c7c56 + f2e40ce commit 600f865

File tree

3 files changed

+156
-111
lines changed

3 files changed

+156
-111
lines changed

.circleci/config.yml

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -323,116 +323,6 @@ jobs:
323323
- store_artifacts:
324324
path: output.tgz
325325

326-
build-doc:
327-
resource_class: xlarge
328-
docker:
329-
- image: cimg/python:3.9-browsers
330-
331-
steps:
332-
- add_ssh_keys:
333-
fingerprints:
334-
- "dc:5f:39:48:00:b4:72:34:e1:d2:c4:e1:1f:d1:e2:ce" #plotlydocbot
335-
336-
- checkout
337-
- browser-tools/install-chrome
338-
- browser-tools/install-chromedriver
339-
- run:
340-
name: Install dependencies
341-
command: |
342-
cd doc
343-
sudo apt-get update
344-
sudo apt-get install rename
345-
curl -LsSf https://astral.sh/uv/install.sh | sh
346-
uv venv
347-
source .venv/bin/activate
348-
uv pip install -r requirements.txt
349-
cd ..
350-
if [ "${CIRCLE_BRANCH}" != "doc-prod" ]; then
351-
uv pip uninstall plotly
352-
uv pip install -e .
353-
fi
354-
355-
- run:
356-
name: make html
357-
command: |
358-
cd doc
359-
source .venv/bin/activate
360-
echo ${mapbox_token} > python/.mapbox_token
361-
make -kj8 || make -kj8
362-
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/front-matter-ci.py > front-matter-ci.py
363-
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/check-or-enforce-order.py > check-or-enforce-order.py
364-
python front-matter-ci.py build/html
365-
python check-or-enforce-order.py build/html
366-
if [ "${CIRCLE_BRANCH}" == "doc-prod" ]; then
367-
cd build/html
368-
git init
369-
git config user.name plotlydocbot
370-
git config user.email accounts@plot.ly
371-
git add *
372-
git commit -m "build of https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
373-
git push --force git@github.com:plotly/plotly.py-docs.git master:built
374-
rm -rf .git
375-
cd ../..
376-
cd build/ipynb
377-
git init
378-
git config user.name plotlydocbot
379-
git config user.email accounts@plot.ly
380-
git add *
381-
git commit -m "build of https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
382-
git push --force git@github.com:plotly/plotly.py-docs.git master:built_ipynb
383-
rm -rf .git
384-
cd ../..
385-
fi
386-
tar -zcf build/html.tgz build/html
387-
rm -rf build/html build/ipynb
388-
cd ..
389-
390-
- run:
391-
name: trigger doc build
392-
command: |
393-
if [ "${CIRCLE_BRANCH}" == "doc-prod" ]; then
394-
git clone --depth=1 https://github.com/plotly/graphing-library-docs.git
395-
cd graphing-library-docs
396-
git config user.name plotlydocbot
397-
git config user.email accounts@plot.ly
398-
git commit --allow-empty -m "deploying https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
399-
git push
400-
cd ..
401-
rm -rf graphing-library-docs
402-
fi
403-
404-
- run:
405-
name: make doc
406-
command: |
407-
cd doc
408-
source .venv/bin/activate
409-
# For the API doc, we need to use the local version of plotly
410-
# since we are tweaking the source because of
411-
# graph_objs/graph_objects
412-
if [ "${CIRCLE_BRANCH}" == "doc-prod" ]; then
413-
uv pip uninstall plotly
414-
cd ..
415-
uv pip install -e .
416-
cd doc
417-
cd apidoc
418-
make html
419-
cd _build/html
420-
touch .nojekyll
421-
git init
422-
git config user.name plotlydocbot
423-
git config user.email accounts@plot.ly
424-
git add *
425-
git add .nojekyll
426-
git commit -m "build of https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
427-
git push --force git@github.com:plotly/plotly.py-docs.git master:gh-pages
428-
rm -rf .git
429-
cd ../..
430-
fi
431-
432-
- store_artifacts:
433-
path: doc/build
434-
destination: doc/build
435-
436326
workflows:
437327
code_formatting:
438328
jobs:
@@ -476,4 +366,3 @@ workflows:
476366
python_version:
477367
- "3.12"
478368
- python_311_percy
479-
- build-doc

.github/workflows/build-doc.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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

doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ requests
3333
scikit-image==0.20.0
3434
scikit-learn
3535
scipy==1.9.1
36+
setuptools<=81
3637
shapely==2.0.5
3738
sphinx==3.5.4
3839
sphinx_bootstrap_theme

0 commit comments

Comments
 (0)