Ensure notebooks from subfolder are fetched when building the docs #29
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: Documentation | |
| on: | |
| push: | |
| branches: | |
| - output # Change to main after merge | |
| paths: | |
| - 'docs/**' | |
| - 'src/**' | |
| - 'mkdocs.yml' | |
| - 'pyproject.toml' | |
| - '.github/workflows/docs.yml' | |
| pull_request: | |
| branches: | |
| - output # Change to main after merge | |
| paths: | |
| - 'docs/**' | |
| - 'src/**' | |
| - 'mkdocs.yml' | |
| workflow_dispatch: # Allow manual trigger | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| jobs: | |
| # Build job | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout rompy-xbeach | |
| uses: actions/checkout@v4 | |
| - name: Checkout rompy-notebooks | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: rom-py/rompy-notebooks | |
| ref: xbeach | |
| path: rompy-notebooks | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-docs-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-docs- | |
| - name: Cache MkDocs Material | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/mkdocs | |
| key: mkdocs-material-${{ github.run_id }} | |
| restore-keys: | | |
| mkdocs-material- | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gdal-bin libgdal-dev | |
| - name: Install package with docs dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[docs]" | |
| - name: Sync notebooks | |
| run: | | |
| mkdir -p docs/examples/components docs/examples/data-interfaces | |
| # Copy main workflow notebooks | |
| cp rompy-notebooks/notebooks/xbeach/*.ipynb docs/examples/ || true | |
| cp rompy-notebooks/notebooks/xbeach/*.yml docs/examples/ || true | |
| # Copy component tutorials | |
| cp rompy-notebooks/notebooks/xbeach/components/*.ipynb docs/examples/components/ || true | |
| # Copy data interface tutorials | |
| cp rompy-notebooks/notebooks/xbeach/data-interface/*.ipynb docs/examples/data-interfaces/ || true | |
| ls -la docs/examples/ | |
| ls -la docs/examples/components/ | |
| ls -la docs/examples/data-interfaces/ | |
| - name: Build documentation | |
| run: mkdocs build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: site/ | |
| # Deployment job (only on push to output branch - change to main after merge) | |
| deploy: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/output' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |