diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0083834..a70d3c7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout Quarto Book uses: actions/checkout@v4 - with: - path: main - name: Checkout Pythia Book uses: actions/checkout@v4 @@ -25,20 +23,29 @@ jobs: - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 + - name: Restore Cache Jupyter Kernels + id: cache-jupyter-kernels-restore + uses: actions/cache/restore@v4 + with: + path: ~/.local/share/jupyter/kernels + key: ${{ runner.os }}-jupyter-${{ hashFiles('chapters/*.yml') }} + - name: Render and Publish id: setup-python uses: quarto-dev/quarto-actions/publish@v2 with: - path: main target: gh-pages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: echo $(ls ~/.local/share/jupyter/kernels) - name: Cache Jupyter Kernels - uses: actions/cache@v3 + id: cache-jupyter-kernels-save + uses: actions/cache/save@v4 with: path: ~/.local/share/jupyter/kernels - key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-jupyter-${{ hashFiles('chapters/*.yml') }} + key: ${{ steps.cache-jupyter-kernels-restore.outputs.cache-primary-key }} # - name: Cache Binder Build on mybinder.org # uses: jupyterhub/repo2docker-action@master @@ -47,15 +54,15 @@ jobs: # MYBINDERORG_TAG: ${{ github.event.ref }} # REPO2DOCKER_EXTRA_ARGS: --subdir notebooks + - run: echo $(ls $(pwd)/notebooks) + - name: Commit Files if: github.ref == 'refs/heads/main' run: | - cp main/notebooks/*.ipynb eo-datascience-cookbook/notebooks/*.ipynb - cd eo-datascience-cookbook + NB_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]ipynb$')) git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add notebooks/*.ipynb - git commit -m "Quarto output" + git commit ${RMD_PATH[*]/.ipynb} -m "Quarto output" - name: Push Commit if: github.ref == 'refs/heads/main' diff --git a/.gitignore b/.gitignore index f316924..b11b2d1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ .env /.quarto/ /_book/ -/data/ -/**/*.ipynb \ No newline at end of file +/data/ \ No newline at end of file diff --git a/Makefile b/Makefile index 76dcb57..a50f195 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ SHELL = /bin/bash .PHONY: help clean environment kernel post-render data YML = $(wildcard chapters/*.yml) +QMD = $(wildcard chapters/*.qmd) REQ = $(basename $(notdir $(YML))) CONDA_ENV_DIR := $(foreach i,$(REQ),$(shell conda info --base)/envs/$(i)) KERNEL_DIR := $(foreach i,$(REQ),$(shell jupyter --data-dir)/kernels/$(i)) @@ -34,7 +35,9 @@ kernel: $(KERNEL_DIR) @echo -e "conda jupyter kernel is ready." post-render: + for i in $(QMD); do quarto convert $$i; done - mv chapters/*.ipynb notebooks/ >/dev/null 2>&1 + - for f in chapters/*.quarto_ipynb ; do mv -- "$f" "${f%.quarto_ipynb}.ipynb" >/dev/null 2>&1; done cp Makefile notebooks/ data: diff --git a/chapters/01_classification.qmd b/chapters/01_classification.qmd index 8dd97af..2f95b6a 100644 --- a/chapters/01_classification.qmd +++ b/chapters/01_classification.qmd @@ -6,7 +6,6 @@ jupyter: name: "01_classification" language: "python" display_name: "01_classification" -keep-ipynb: true --- ```{python} diff --git a/chapters/02_floodmapping.qmd b/chapters/02_floodmapping.qmd index 286c6eb..413a4d4 100644 --- a/chapters/02_floodmapping.qmd +++ b/chapters/02_floodmapping.qmd @@ -6,8 +6,6 @@ jupyter: name: "02_floodmapping" language: "python" display_name: "02_floodmapping" -keep-ipynb: true -code-fold: true --- ![Image from [wikipedia](https://upload.wikimedia.org/wikipedia/commons/d/d4/Thomas_Bayes.gif)](https://upload.wikimedia.org/wikipedia/commons/d/d4/Thomas_Bayes.gif)