Update build.yml #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy | |
| on: | |
| push: | |
| branches-ignore: | |
| - gh-pages | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '2.7' | |
| bundler-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Install Python dependencies | |
| run: uv pip install --system PyYAML==6.0.1 python-frontmatter==0.5.0 | |
| - name: Fetch upstream docs | |
| run: make fetch_upstream_files | |
| - name: Fix case-sensitive redirect issues | |
| run: python fix-case-redirects.py _posts/julia/html | |
| - name: Set up Mapbox token | |
| run: | | |
| echo "token: ${{ secrets.MAPBOX_TOKEN }}" > _data/mapbox_token.yml | |
| - name: Build site | |
| run: | | |
| python front-matter-ci.py _posts | |
| python check-or-enforce-order.py _posts/python | |
| python check-or-enforce-order.py _posts/python-v3 | |
| python check-or-enforce-order.py _posts/r/ | |
| python check-or-enforce-order.py _posts/matlab | |
| python check-or-enforce-order.py _posts/plotly_js | |
| python generate-sitemaps.py | |
| md5sum all_static/css/main.css | cut -d ' ' -f 1 > _data/cache_bust_css.yml | |
| bundle exec jekyll build | |
| cp python/sitemap.xml _site/python/sitemap.xml | |
| rm _data/mapbox_token.yml | |
| - name: Create Percy snapshots | |
| run: | | |
| mkdir snapshots | |
| cd _site | |
| cp -r 'all_static' '../snapshots' | |
| cp 'api/index.html' '../snapshots' | |
| cp --parents 'python/index.html' '../snapshots' | |
| cp --parents 'python/getting-started/index.html' '../snapshots' | |
| cp --parents 'python/plotly-fundamentals/index.html' '../snapshots' | |
| cp --parents 'python/line-and-scatter/index.html' '../snapshots' | |
| cp --parents 'r/index.html' '../snapshots' | |
| cp --parents 'r/getting-started/index.html' '../snapshots' | |
| cp --parents 'r/plotly-fundamentals/index.html' '../snapshots' | |
| cp --parents 'r/line-and-scatter/index.html' '../snapshots' | |
| cp --parents 'javascript/index.html' '../snapshots' | |
| cp --parents 'javascript/plotly-fundamentals/index.html' '../snapshots' | |
| cp --parents 'javascript/getting-started/index.html' '../snapshots' | |
| cp --parents 'javascript/line-and-scatter/index.html' '../snapshots' | |
| cp --parents 'ggplot2/index.html' '../snapshots' | |
| cp --parents 'ggplot2/getting-started/index.html' '../snapshots' | |
| cp --parents 'ggplot2/histograms/index.html' '../snapshots' | |
| cp --parents 'matlab/index.html' '../snapshots' | |
| cp --parents 'matlab/getting-started/index.html' '../snapshots' | |
| cp --parents 'matlab/graphing-multiple-chart-types/index.html' '../snapshots' | |
| cp --parents 'matlab/histograms/index.html' '../snapshots' | |
| cp --parents 'csharp/index.html' '../snapshots' | |
| cp --parents 'csharp/getting-started/index.html' '../snapshots' | |
| cd .. | |
| rm -f 'snapshots/all_static/javascripts/jquery-knob/index.html' | |
| rm -f 'snapshots/all_static/images/Plotly-feed2.html' | |
| rm -f 'snapshots/all_static/images/Plotly.html' | |
| rm -f 'snapshots/all_static/images/Plotly-Feed.html' | |
| rm -f snapshots/*.bkp snapshots/*/*.bkp snapshots/*/*/*.bkp | |
| - name: Percy snapshot | |
| run: bundle exec percy snapshot snapshots --enable_javascript | |
| env: | |
| PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
| - name: Remove files with invalid characters | |
| run: rm -rf _site/https:* 2>/dev/null || true | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: site-build | |
| path: _site/ | |
| - name: Create GitHub App token | |
| if: github.ref_name == 'update-ci' && github.repository == 'plotly/graphing-library-docs' | |
| uses: actions/create-github-app-token@v2 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.GRAPHING_LIBRARIES_CI_GHAPP_ID }} | |
| private-key: ${{ secrets.GRAPHING_LIBRARIES_CI_GHAPP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: documentation | |
| - name: Checkout documentation repo | |
| if: github.ref_name == 'update-ci' && github.repository == 'plotly/graphing-library-docs' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: plotly/documentation | |
| ref: test-pages | |
| token: ${{ steps.app-token.outputs.token }} | |
| path: documentation | |
| - name: Deploy to test branch | |
| if: github.ref_name == 'update-ci' && github.repository == 'plotly/graphing-library-docs' | |
| run: | | |
| git config --global user.email "accounts@plot.ly" | |
| git config --global user.name "plotlydocbot" | |
| cp -r _site/* documentation/ | |
| cd documentation | |
| git add . | |
| git commit -m "deploying https://github.com/plotly/graphing-library-docs/commit/${{ github.sha }}" || echo "No changes to commit" | |
| git push |