build documentation #3552
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
| # build the documentation and upload the built artifact | |
| name: build documentation | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| merge_group: | |
| push: | |
| branches: [main] | |
| workflow_run: | |
| workflows: | |
| - "contributor check" | |
| types: | |
| - completed | |
| env: | |
| # `BASE_URL` determines, relative to the root of the domain, the URL that your site is served from. | |
| # E.g., if your site lives at `https://mydomain.org/myproject`, set `BASE_URL=/myproject`. | |
| # If, instead, your site lives at the root of the domain, at `https://mydomain.org`, set `BASE_URL=''`. | |
| BASE_URL: '' | |
| jobs: | |
| build: | |
| runs-on: 4-core-ubuntu-gpu-t4 | |
| permissions: | |
| contents: read | |
| # Needed to manually set commit status | |
| statuses: write | |
| steps: | |
| # Check out the code | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| # The path to the sha of the commit we want to build will depend | |
| # on the trigger type. If a workflow_run trigger, then we want | |
| # the sha from the head of the branch that triggered it. For | |
| # pushes and manual triggers, we want the sha of the branch. | |
| ref: | | |
| ${{ | |
| github.event.workflow_run.head_sha || | |
| github.event.pull_request.head.sha || | |
| github.sha | |
| }} | |
| # Optional: get full history if needed | |
| fetch-depth: 0 | |
| - name: Setup | |
| uses: ./.github/actions/multi-trigger-setup | |
| with: | |
| status-context: '${{ github.job }}' | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 18.x | |
| - name: Install Jupyter Book (via myst) | |
| run: npm install -g jupyter-book | |
| - name: Install latexmk | |
| run: sudo apt-get update && sudo apt-get -y install latexmk pandoc ffmpeg imagemagick texlive-xetex | |
| # Install dependencies | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.12 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install \ | |
| packages/fairchem-core[docs,adsorbml,extras] \ | |
| packages/fairchem-data-oc[dev] \ | |
| packages/fairchem-applications-cattsunami \ | |
| packages/fairchem-data-omat \ | |
| -r tests/requirements.txt # pin test packages | |
| # Build the book | |
| - name: Build the book | |
| env: | |
| QUACC_CONFIG_FILE: docs/.quacc.yml | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| # Set FAST_DOCS only if not a push to main | |
| FAST_DOCS: ${{ (github.event_name != 'push' || github.ref != 'refs/heads/main') && 'true' || '' }} | |
| run: | | |
| # Convert MyST markdown files to Jupyter notebooks if needed to get download as ipynb buttons | |
| jupytext --to ipynb ./docs/uma_tutorials/*.md | |
| find ./docs/ -name "*.md" -exec grep -q "format_name: myst" {} \; -print0 | xargs -0 jupytext --to ipynb | |
| cd docs && jupyter-book build --html --execute --execute-parallel 1 | |
| - name: Upload documentation artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: docs-html | |
| path: docs/_build/html/* | |
| - name: Cleanup | |
| if: always() | |
| uses: ./.github/actions/multi-trigger-cleanup | |
| with: | |
| status-context: '${{ github.job }}' |