From 5fb83774f32a56a2c1beb89ebc57ca426d240d80 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:02:53 +0200 Subject: [PATCH 1/7] pages --- .github/workflows/deploy.yml | 96 +++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74a326c..2945b1f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,52 +1,58 @@ -name: deploy +name: deploy-book on: # Trigger the deploy on push to main branch push: branches: - main - schedule: - # jupyter-book is updated regularly, let's run this deployment every month in case something fails - # - # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07 - # https://crontab.guru/every-month - # Run cron job every month - - cron: '0 0 1 * *' - -jobs: - # This job deploys the example book - deploy-example-book: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.8] + +env: + BASE_URL: /${{ github.event.repository.name }} + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + deploy-book: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - # Install CC - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install -r requirements.txt - # Use default CC - - name: Cookiecutter no GHA - run: | - cookiecutter . --no-input include_ci=no - # Install requirements.txt - - name: Install requirements - run: | - pip install -r my_book/requirements.txt - # Build the example book - - name: Build book - run: | - jupyter-book build my_book/my_book/ - # Deploy html to gh-pages - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: my_book/my_book/_build/html - publish_branch: gh-pages + - uses: actions/checkout@v3 + + # Install dependencies + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + pip install -r requirements.txt + + # Build the book + - name: Build the book + run: | + jupyter-book build . + + # Setup for GitHub Pages deployment + - name: Setup Pages + uses: actions/configure-pages@v3 + + # Upload the book's HTML as an artifact (optional) + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: "./_build/html" + + # Deploy the book's HTML to GitHub Pages + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 From 0716b2800f2dec320c2753bc5198f3443d7f9d7a Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:45:05 +0200 Subject: [PATCH 2/7] add in cookiecutter --- .../.github/workflows/deploy.yml | 79 ++++++++++++------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml index ca44778..1dede6c 100644 --- a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml +++ b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: deploy +name: deploy-book on: # Trigger the workflow on push to main branch @@ -6,34 +6,53 @@ on: branches: - main -# This job installs dependencies, build the book, and pushes it to `gh-pages` +env: + BASE_URL: /${{ github.event.repository.name }} + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + jobs: - build-and-deploy-book: - runs-on: {% raw %}${{ matrix.os }}{% endraw %} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.8] + deploy-book: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - # Install dependencies - - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v1 - with: - python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - - name: Install dependencies - run: | - pip install -r requirements.txt - - # Build the book - - name: Build the book - run: | - jupyter-book build {{ cookiecutter.book_slug }} - - # Deploy the book's HTML to gh-pages branch - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 - with: - github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} - publish_dir: {{ cookiecutter.book_slug }}/_build/html \ No newline at end of file + - uses: actions/checkout@v3 + + # Install dependencies + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + pip install -r requirements.txt + + # Build the book + - name: Build the book + run: | + jupyter-book build . + + # Setup for GitHub Pages deployment + - name: Setup Pages + uses: actions/configure-pages@v3 + + # Upload the book's HTML as an artifact (optional) + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: "./_build/html" + + # Deploy the book's HTML to GitHub Pages + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 From debcfd62a8ad9b45d909f1026af391a73731578a Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 1 Nov 2023 12:08:06 +0000 Subject: [PATCH 3/7] fix: wrap template in `raw` --- {{cookiecutter.book_slug}}/.github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml index 1dede6c..dd97cb6 100644 --- a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml +++ b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml @@ -7,7 +7,7 @@ on: - main env: - BASE_URL: /${{ github.event.repository.name }} + BASE_URL: {% raw %}/${{ github.event.repository.name }}{% endraw %} # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: From 875904e74b6af7caf418fd5d55c4ad8e1bf1b223 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 1 Nov 2023 20:06:10 +0000 Subject: [PATCH 4/7] ci: remove redundant configure step --- .github/workflows/deploy.yml | 8 ++------ {{cookiecutter.book_slug}}/.github/workflows/deploy.yml | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2945b1f..e158179 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,15 +42,11 @@ jobs: run: | jupyter-book build . - # Setup for GitHub Pages deployment - - name: Setup Pages - uses: actions/configure-pages@v3 - # Upload the book's HTML as an artifact (optional) - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v2 with: - path: "./_build/html" + path: "_build/html" # Deploy the book's HTML to GitHub Pages - name: Deploy to GitHub Pages diff --git a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml index dd97cb6..184fa5a 100644 --- a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml +++ b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml @@ -42,15 +42,11 @@ jobs: run: | jupyter-book build . - # Setup for GitHub Pages deployment - - name: Setup Pages - uses: actions/configure-pages@v3 - # Upload the book's HTML as an artifact (optional) - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v2 with: - path: "./_build/html" + path: "_build/html" # Deploy the book's HTML to GitHub Pages - name: Deploy to GitHub Pages From a2125112e33ac8d6fe1c92eede0eb48083e596db Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 1 Nov 2023 20:12:57 +0000 Subject: [PATCH 5/7] ci: deploy test --- .github/workflows/deploy.yml | 2 +- .github/workflows/tests.yml | 29 +++++++++++-------- .../.github/workflows/deploy.yml | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e158179..22df676 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,7 +42,7 @@ jobs: run: | jupyter-book build . - # Upload the book's HTML as an artifact (optional) + # Upload the book's HTML as an artifact - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24feaa3..8bfcff8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,12 @@ on: - cron: '0 0 1 * *' workflow_dispatch: +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + jobs: # This job tests that the CC works test-cc-and-jb-build: @@ -22,12 +28,13 @@ jobs: os: [ubuntu-latest] # currently not testing on windows python-version: [3.9] steps: - - uses: actions/checkout@v2 - # Setup - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + - uses: actions/checkout@v3 + + # Install dependencies + - name: Set up Python 3.11 + uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: 3.11 - name: Install dependencies run: | pip install -r requirements.txt @@ -44,11 +51,9 @@ jobs: run: | cookiecutter . --no-input --overwrite-if-exists pip install -r my_book/requirements.txt - jupyter-book build my_book/my_book/ - # Push example book to gh-pages-test - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 + jupyter-book build . + # Upload the book's HTML as an artifact + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: my_book/my_book/_build/html - publish_branch: gh-pages-test + path: "_build/html" \ No newline at end of file diff --git a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml index 184fa5a..5e9120c 100644 --- a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml +++ b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml @@ -42,7 +42,7 @@ jobs: run: | jupyter-book build . - # Upload the book's HTML as an artifact (optional) + # Upload the book's HTML as an artifact - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: From cc7cffb18c492b48c9e70a9d00ed740cf6f4342e Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 1 Nov 2023 20:42:48 +0000 Subject: [PATCH 6/7] ci: reflect cookiecutter paths --- .github/workflows/deploy.yml | 19 ++++++++++++------- .github/workflows/tests.yml | 20 +++++++++++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22df676..6aad29c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,18 +36,23 @@ jobs: - name: Install dependencies run: | pip install -r requirements.txt - - # Build the book - - name: Build the book + # Use default CC + - name: Cookiecutter no GHA run: | - jupyter-book build . - + cookiecutter . --no-input include_ci=no + # Install requirements.txt + - name: Install requirements + run: | + pip install -r my_book/requirements.txt + # Build the example book + - name: Build book + run: | + jupyter-book build my_book/my_book/ # Upload the book's HTML as an artifact - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: - path: "_build/html" - + path: "my_book/my_book/_build/html" # Deploy the book's HTML to GitHub Pages - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bfcff8..13ef0c6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,14 +46,24 @@ jobs: - name: Pytest tests run: | pytest - # Build the example book - - name: Build default book + # Use default CC + - name: Cookiecutter no GHA + run: | + cookiecutter . --no-input --overwrite-if-exists include_ci=no + # Install requirements.txt + - name: Install requirements run: | - cookiecutter . --no-input --overwrite-if-exists pip install -r my_book/requirements.txt - jupyter-book build . + # Build the example book + - name: Build book + run: | + jupyter-book build my_book/my_book/ # Upload the book's HTML as an artifact - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: - path: "_build/html" \ No newline at end of file + path: "my_book/my_book/_build/html" + # Deploy the book's HTML to GitHub Pages + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file From 0e85c3f6dbed35826b353b166172388413ccf43b Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 1 Nov 2023 20:46:33 +0000 Subject: [PATCH 7/7] ci: more fixes --- .github/workflows/deploy.yml | 10 ++++------ .github/workflows/tests.yml | 16 +++++----------- .../.github/workflows/deploy.yml | 10 ++++------ 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6aad29c..cc26305 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,12 +9,6 @@ on: env: BASE_URL: /${{ github.event.repository.name }} -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: @@ -24,6 +18,10 @@ concurrency: jobs: deploy-book: runs-on: ubuntu-latest + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + pages: write + id-token: write steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13ef0c6..cf4e7c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,20 +13,14 @@ on: - cron: '0 0 1 * *' workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - jobs: # This job tests that the CC works test-cc-and-jb-build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] # currently not testing on windows - python-version: [3.9] + runs-on: ubuntu-latest + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + pages: write + id-token: write steps: - uses: actions/checkout@v3 diff --git a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml index 5e9120c..59e8dc5 100644 --- a/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml +++ b/{{cookiecutter.book_slug}}/.github/workflows/deploy.yml @@ -9,12 +9,6 @@ on: env: BASE_URL: {% raw %}/${{ github.event.repository.name }}{% endraw %} -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: @@ -24,6 +18,10 @@ concurrency: jobs: deploy-book: runs-on: ubuntu-latest + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + pages: write + id-token: write steps: - uses: actions/checkout@v3