diff --git a/.github/workflows/netlify-test.yaml b/.github/workflows/netlify-test.yaml index 7e3050083..53b1597e1 100644 --- a/.github/workflows/netlify-test.yaml +++ b/.github/workflows/netlify-test.yaml @@ -27,13 +27,12 @@ jobs: conda list - name: Build to md run: | + git diff --name-only origin/master origin/${GITHUB_HEAD_REF} >> diff + python build/tweak_render.py quarto render --to hugo mv content/course/manipulation/index.md content/course/manipulation/_index.md mv content/course/visualisation/index.md content/course/visualisation/_index.md mv content/course/modelisation/index.md content/course/modelisation/_index.md - #git diff --name-only origin/master origin/${GITHUB_HEAD_REF} >> diff.txt - #cat diff.txt - #Rscript -e 'source("./build/build_light.R")' hugo mod graph hugo -D --themesDir themes -t github.com - name: Clean files with Python function @@ -77,8 +76,6 @@ jobs: run: | git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' - # git config user.email github-actions@github.com - #git checkout ${BRANCHE_REF} git status find notebooks -type f -name "*.ipynb" | xargs git add git commit -m "Automated changes"; @@ -103,6 +100,8 @@ jobs: conda list - name: Convert in ipynb with Jupytext run: | + git diff --name-only origin/master origin/${GITHUB_HEAD_REF} >> diff + python build/tweak_render.py quarto render content --to ipynb --execute mkdir -p corrections python build/move_files.py corrections diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index a34f176f8..301819710 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -45,12 +45,10 @@ jobs: mkdir -p notebooks python build/move_files.py notebooks - name: Install npm - if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} uses: actions/setup-node@v2 with: node-version: '12' - name: Deploy to Netlify - if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} # NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID added in the repo's secrets env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} diff --git a/build/tweak_render.py b/build/tweak_render.py new file mode 100644 index 000000000..aa737481c --- /dev/null +++ b/build/tweak_render.py @@ -0,0 +1,17 @@ +import yaml + +with open("_quarto.yml", "r") as stream: + config = yaml.load(stream, Loader=yaml.FullLoader) + +with open('diff') as f: + lines = f.read().splitlines() + +lines = [l for l in lines if l.endswith('.qmd') ] +lines += [f"content/course/{dir}/index.md" for dir in ["manipulation","visualisation","modelisation"]] + +config['project']['render'] = lines + +with open('_quarto.yml', 'w') as outfile: + yaml.dump(config, outfile, default_flow_style=False) + +print("Done") \ No newline at end of file diff --git a/content/course/manipulation/numpy/index.qmd b/content/course/manipulation/01_numpy/index.qmd similarity index 100% rename from content/course/manipulation/numpy/index.qmd rename to content/course/manipulation/01_numpy/index.qmd diff --git a/sspcloud/generate-doc.py b/sspcloud/generate-doc.py index 0355fa78e..33e5a0b1a 100644 --- a/sspcloud/generate-doc.py +++ b/sspcloud/generate-doc.py @@ -83,12 +83,12 @@ def generate_block(name, abstract, authors, types, tags, category, if section_md["chapters"]: for chapter in section_md["chapters"]: # Build chapter block if notebook exists - MD_PATH = os.path.join(PROJECT_DIR, "content", "course", section, f"{chapter}.Rmd") + MD_PATH = os.path.join(PROJECT_DIR, "content", "course", section, chapter, "index.qmd") if os.path.isfile(MD_PATH): name, abstract = extract_metadata_md(MD_PATH) - init_args = urllib.parse.quote(f"{section} {chapter}") + init_args = urllib.parse.quote(f"{section} {chapter}.ipynb") launcher_url = LAUNCHER_TMPLT.format(init_args=init_args) chapter_doc = generate_block(name=name,