Skip to content

Commit

Permalink
Merge pull request #46 from m2lines/fix/preview-5
Browse files Browse the repository at this point in the history
Fix preview - attempt 5
  • Loading branch information
LaureZanna authored Apr 5, 2024
2 parents 0eab033 + f34cae3 commit f3a7992
Show file tree
Hide file tree
Showing 29 changed files with 20 additions and 102 deletions.
73 changes: 15 additions & 58 deletions .github/workflows/publish-book.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,22 @@

name: publish-book

# Trigger the workflow on push to main branch
on:
# Trigger the workflow on push to main branch
push:
branches:
- main
# This job installs dependencies, builds the book, and deploys the html
workflow_dispatch:

jobs:
build-and-deploy-book:
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: src/_build/.jupyter_cache
key: notebook_cache-${{hashFiles('_toc.yml', '_config.yml', 'environment.yml') }}
- name: 📖 Build the book
shell: bash -l {0}
run: |
cd src
mkdir -p _notebook_cache
jupyter-book build .
- name: 📖 Show logs from the book build
shell: bash -l {0}
run: |
find src/_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/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: src/_build/html
keep_files: false
force_orphan: true
build:
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
with:
environment_name: DGM2lines
path_to_notebooks: 'book'

deploy:
needs: build
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
with:
publish_dir: "book/_build/html"
40 changes: 2 additions & 38 deletions .github/workflows/trigger-book-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,11 @@ 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"
path_to_notebooks: "book"
build_command: "jupyter-book build --keep-going ."
# Other input options are possible, see ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml
7 changes: 2 additions & 5 deletions .github/workflows/trigger-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
- requested
- completed

permissions:
contents: write

jobs:
find-pull-request:
uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main
Expand All @@ -21,8 +18,8 @@ jobs:
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"
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "book/_build/html"
# cname: foundations.projectpythia.org

preview-comment:
needs: find-pull-request
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _build/
*.npz
*.pth
_build/*
src/_build/*
book/_build/*
_notebook_cache/*
notebooks/Source.gv
notebooks/*.pkl
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f3a7992

Please sign in to comment.