|
| 1 | +name: GitHub pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger the workflow on push to main branch |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +# This job installs dependencies, build the book, and pushes it to `gh-pages` |
| 10 | +jobs: |
| 11 | + build-and-deploy-book: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + label: linux-64 |
| 17 | + prefix: /usr/share/miniconda3/envs/oasismove |
| 18 | + |
| 19 | + # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell |
| 20 | + defaults: |
| 21 | + run: |
| 22 | + shell: bash -l {0} |
| 23 | + |
| 24 | + name: Build OasisMove documentation ${{ matrix.label }} |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Upgrade pip and setuptools |
| 32 | + run: | |
| 33 | + python3 -m pip install pip setuptools --upgrade |
| 34 | + |
| 35 | + # See: https://github.com/marketplace/actions/setup-miniconda |
| 36 | + - name: Setup miniconda |
| 37 | + uses: conda-incubator/setup-miniconda@v2 |
| 38 | + with: |
| 39 | + auto-update-conda: true |
| 40 | + miniforge-variant: Mambaforge |
| 41 | + channels: conda-forge |
| 42 | + python-version: 3.8 |
| 43 | + activate-environment: oasismove |
| 44 | + environment-file: environment.yml |
| 45 | + use-mamba: true |
| 46 | + |
| 47 | + - name: Set cache date |
| 48 | + run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV |
| 49 | + |
| 50 | + - uses: actions/cache@v2 |
| 51 | + with: |
| 52 | + path: ${{ matrix.prefix }} |
| 53 | + key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }} |
| 54 | + id: cache |
| 55 | + |
| 56 | + - name: Update environment |
| 57 | + run: mamba env update -n oasismove -f environment.yml |
| 58 | + if: steps.cache.outputs.cache-hit != 'true' |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: | |
| 62 | + pip install -r requirements.txt |
| 63 | +
|
| 64 | + - name: Install VaMPy |
| 65 | + run: python3 -m pip install .[test] |
| 66 | + |
| 67 | + # Build the book |
| 68 | + - name: Build the book |
| 69 | + run: | |
| 70 | + jupyter-book build docs |
| 71 | +
|
| 72 | + # Deploy the book's HTML to gh-pages branch |
| 73 | + - name: GitHub Pages action |
| 74 | + |
| 75 | + with: |
| 76 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + publish_dir: docs/_build/html |
0 commit comments