ci(docs): serialize gh-pages deploys to fix the "cannot lock ref" rac… #807
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
| # This workflow builds the sphinx docs | |
| name: Sphinx Docs Build | |
| on: | |
| push: | |
| pull_request: | |
| # Serialize runs for the same ref so two near-simultaneous pushes to main | |
| # don't race to force-push gh-pages. Without this, the second deploy fails | |
| # with "cannot lock ref 'refs/heads/gh-pages'" because the first run advanced | |
| # the branch after the second had already read its tip. Queue rather than | |
| # cancel (cancel-in-progress: false) so every commit's docs still deploy. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| cache: "pip" | |
| - name: Install dataretrieval, dependencies, and Sphinx then build docs | |
| shell: bash -l {0} | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[doc,nldi] | |
| ipython kernel install --name "python3" --user | |
| sudo apt update -y && sudo apt install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended dvipng pandoc | |
| (cd docs && make html) | |
| - name: Debug | |
| run: | | |
| echo $REF | |
| echo $EVENT_NAME | |
| echo ${{ github.event_name == 'push' }} | |
| echo ${{ github.ref == 'refs/heads/main' }} | |
| echo ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| REF: ${{ github.ref }} | |
| BRANCH: gh-pages | |
| FOLDER: docs/build/html |