diff --git a/.github/workflows/deploy.yml b/.github/workflows/publish-book.yml similarity index 92% rename from .github/workflows/deploy.yml rename to .github/workflows/publish-book.yml index dd9c9a6..7097313 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/publish-book.yml @@ -1,7 +1,10 @@ -name: build-and-deploy-book +name: publish-book -# Trigger the workflow on push to main branch and PRs -on: [push, pull_request] +# Trigger the workflow on push to main branch +on: + push: + branches: + - main # This job installs dependencies, builds the book, and deploys the html jobs: build-and-deploy-book: @@ -51,6 +54,7 @@ jobs: run: | find _build/html -name "*.log" -print -exec cat {} \; - name: 🚀 Deploy to GitHub Pages + # redudant but keeping for testing purposes if: github.ref == 'refs/heads/main' uses: peaceiris/actions-gh-pages@v3.9.3 with: diff --git a/.github/workflows/trigger-book-build.yml b/.github/workflows/trigger-book-build.yml new file mode 100644 index 0000000..bbb1d3d --- /dev/null +++ b/.github/workflows/trigger-book-build.yml @@ -0,0 +1,49 @@ +name: trigger-book-build +on: + pull_request: + +jobs: + install-dependencies: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.9] + steps: + - uses: actions/checkout@v2 + - name: Get PR number + run: echo "Your PR is ${PR}" + env: + PR: ${{ github.event.pull_request.number }} + - name: 📦 Cache Conda Packages + uses: actions/cache@v2 + env: + # Increase this value to reset cache if etc/example-environment.yml has not changed + CACHE_NUMBER: 0 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda-linux-64.lock') }} + - name: 🐍 Set up Conda environment + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: false + activate-environment: DGM2lines + environment-file: conda-linux-64.lock + - name: 👀 Check Conda environment + shell: bash -l {0} + run: | + pip install -r requirements.txt + conda info + conda list + - name: 📦 Cache Notebooks + uses: actions/cache@v2 + with: + path: _build/.jupyter_cache + key: notebook_cache-${{hashFiles('_toc.yml', '_config.yml', 'environment.yml') }} + build: + uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main + with: + environment_name: DGM2lines + artifact_name: book-zip-${{ github.event.number }} + path_to_notebooks: "src" + build_command: "jupyter-book build --keep-going ." diff --git a/.github/workflows/trigger-delete-preview.yml b/.github/workflows/trigger-delete-preview.yml new file mode 100644 index 0000000..06e13e5 --- /dev/null +++ b/.github/workflows/trigger-delete-preview.yml @@ -0,0 +1,9 @@ +name: trigger-delete-preview + +on: + pull_request_target: + types: closed + +jobs: + delete: + uses: ProjectPythia/cookbook-actions/.github/workflows/delete-preview.yaml@main diff --git a/.github/workflows/trigger-preview.yml b/.github/workflows/trigger-preview.yml new file mode 100644 index 0000000..304256f --- /dev/null +++ b/.github/workflows/trigger-preview.yml @@ -0,0 +1,29 @@ +name: trigger-preview +on: + workflow_run: + workflows: + - trigger-book-build + types: + - requested + - completed +permissions: + pull-requests: write +jobs: + find-pull-request: + uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main + deploy-preview: + needs: find-pull-request + if: github.event.workflow_run.conclusion == 'success' + uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main + with: + artifact_name: book-zip-${{ needs.find-pull-request.outputs.number }} + destination_dir: _preview/${{ needs.find-pull-request.outputs.number }} # deploy to subdirectory labeled with PR number + is_preview: 'true' + publish_dir: "src/_build/html" + + preview-comment: + needs: find-pull-request + uses: ProjectPythia/cookbook-actions/.github/workflows/preview-comment.yaml@main + with: + pull_request_number: ${{ needs.find-pull-request.outputs.number }} + sha: ${{ needs.find-pull-request.outputs.sha }} diff --git a/.gitignore b/.gitignore index 89ef4f2..4cd56f4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,13 +6,9 @@ __pycache__ *.jpeg *.npz *.pth -_build/* +src/_build/* _notebook_cache/* -notebooks/figs/symbolic_regression.png -notebooks/figs/symbolic_regression_pw.png notebooks/Source.gv notebooks/*.pkl notebooks/*.csv* -notebooks/figs/symbolic_regression.svg -notebooks/figs/symbolic_regression_pw.svg dataset* diff --git a/_config.yml b/src/_config.yml similarity index 100% rename from _config.yml rename to src/_config.yml diff --git a/_toc.yml b/src/_toc.yml similarity index 100% rename from _toc.yml rename to src/_toc.yml diff --git a/assets/newlogo.png b/src/assets/newlogo.png similarity index 100% rename from assets/newlogo.png rename to src/assets/newlogo.png diff --git a/intro.md b/src/intro.md similarity index 100% rename from intro.md rename to src/intro.md diff --git a/notebooks/xarray_intro.ipynb b/src/notebooks/xarray_intro.ipynb similarity index 100% rename from notebooks/xarray_intro.ipynb rename to src/notebooks/xarray_intro.ipynb diff --git a/notebooks/xgcm_intro.ipynb b/src/notebooks/xgcm_intro.ipynb similarity index 100% rename from notebooks/xgcm_intro.ipynb rename to src/notebooks/xgcm_intro.ipynb diff --git a/references.bib b/src/references.bib similarity index 100% rename from references.bib rename to src/references.bib