99jobs :
1010 build-and-deploy :
1111 runs-on : ubuntu-latest
12+ env :
13+ HAS_CF_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN != '' }}
1214
1315 steps :
1416 - name : Checkout code
@@ -17,94 +19,47 @@ jobs:
1719 - name : Setup R
1820 uses : r-lib/actions/setup-r@v2
1921 with :
20- r-version : ' 4.3'
22+ r-version : ' release'
23+ use-public-rspm : true
2124
2225 - name : Install R packages
23- run : |
24- R -e "install.packages(c('ggplot2', 'mgcv'), repos='https://cran.rstudio.com/')"
25-
26- - name : Verify R installation
27- run : |
28- echo "R_HOME=$R_HOME"
29- R --version
30- R -e "library(ggplot2); library(mgcv); cat('R packages loaded successfully\n')"
31-
32- - name : Setup Python
33- uses : actions/setup-python@v5
34- with :
35- python-version : ' 3.11'
26+ run : R -e "install.packages(c('ggplot2', 'mgcv'))"
3627
3728 - name : Install uv
38- run : |
39- curl -LsSf https://astral.sh/uv/install.sh | sh
40- echo "$HOME/.cargo/bin" >> $GITHUB_PATH
29+ uses : astral-sh/setup-uv@v5
30+ with :
31+ enable-cache : true
4132
4233 - name : Install Python dependencies
43- run : |
44- uv pip install -r requirements.txt --system
34+ run : uv sync
4535
4636 - name : Install Chrome for Kaleido
47- run : |
48- uv run kaleido_get_chrome
49-
50- - name : Verify Python packages
51- run : |
52- python -c "import pandas, plotly, seaborn, plotnine, altair, rpy2; print('Python packages imported successfully')"
53-
54- - name : Setup Firefox for Selenium
55- uses : browser-actions/setup-firefox@v1
56-
57- - name : Install geckodriver
58- run : |
59- wget -q https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz
60- tar -xzf geckodriver-v0.34.0-linux64.tar.gz
61- sudo mv geckodriver /usr/local/bin/
62- geckodriver --version
63-
64- - name : Setup Xvfb (virtual display)
65- run : |
66- sudo apt-get update
67- sudo apt-get install -y xvfb
37+ run : uv run kaleido_get_chrome
6838
6939 - name : Run tests
70- run : |
71- xvfb-run -a python -m pytest tests/ -v
72- env :
73- R_HOME : /opt/R/4.3.3/lib/R
40+ run : uv run pytest tests/ -v
41+
42+ - name : Execute notebook
43+ run : uv run jupyter nbconvert --to notebook --execute Examples.ipynb --output Examples.build.ipynb
7444
75- - name : Build site
76- run : |
77- xvfb-run -a make travis
78- env :
79- R_HOME : /opt/R/4.3.3/lib/R
45+ - name : Render site
46+ run : uv run python render.py Examples.build.ipynb
8047
81- - name : Deploy to Netlify (Production)
82- if : github.ref == 'refs/heads/master' && github.event_name == 'push'
83- uses : nwtgck/actions-netlify @v3
48+ - name : Deploy to Cloudflare Pages (Production)
49+ if : github.ref == 'refs/heads/master' && github.event_name == 'push' && env.HAS_CF_TOKEN == 'true'
50+ uses : cloudflare/wrangler-action @v3
8451 with :
85- publish-dir : ./web
86- production-deploy : true
87- github-token : ${{ secrets.GITHUB_TOKEN }}
88- deploy-message : " Deploy from GitHub Actions - ${{ github.event.head_commit.message }}"
89- enable-pull-request-comment : false
90- enable-commit-comment : false
91- env :
92- NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
93- NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }}
52+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
53+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
54+ command : pages deploy web --project-name=pythonplot --branch=main
9455
95- - name : Deploy to Netlify (Preview)
96- if : github.ref != 'refs/heads/master'
97- uses : nwtgck/actions-netlify @v3
56+ - name : Deploy to Cloudflare Pages (Preview)
57+ if : github.ref != 'refs/heads/master' && env.HAS_CF_TOKEN == 'true'
58+ uses : cloudflare/wrangler-action @v3
9859 with :
99- publish-dir : ./web
100- production-deploy : false
101- github-token : ${{ secrets.GITHUB_TOKEN }}
102- deploy-message : " Preview deploy from GitHub Actions"
103- enable-pull-request-comment : true
104- enable-commit-comment : false
105- env :
106- NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
107- NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }}
60+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
61+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
62+ command : pages deploy web --project-name=pythonplot --branch=${{ github.head_ref || github.ref_name }}
10863
10964 - name : Upload build artifacts
11065 if : always()
0 commit comments