diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml new file mode 100644 index 0000000..5952444 --- /dev/null +++ b/.github/workflows/build_docs.yml @@ -0,0 +1,36 @@ +name: Build documentation + +on: + pull_request: + branches: [main] + workflow_call: + workflow_dispatch: + + +jobs: + + build: + runs-on: ubuntu-22.04 + env: + PUBLISH_DIR: ./_build/html + + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + + - name: Install dependencies + run: python3 -m pip install -r requirements.txt + + - name: Build docs + run: jupyter-book build -W --keep-going . + + - name: Upload artifact + uses: actions/upload-pages-artifact@v4 + with: + path: ${{ env.PUBLISH_DIR }} diff --git a/.github/workflows/build_pages.yml b/.github/workflows/build_pages.yml deleted file mode 100644 index fa35b79..0000000 --- a/.github/workflows/build_pages.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages - -on: - # Runs on pushes targeting the default branch - push: - branches: - - "**" - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -env: - # Directory that will be published on github pages - PUBLISH_DIR: ./_build/html - -jobs: - - build: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install dependencies - run: python3 -m pip install jupyter-book - - - name: Build docs - run: jupyter book build -W . - - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: ${{ env.PUBLISH_DIR }} - - # Single deploy job since we're just deploying - deploy: - if: github.ref == 'refs/heads/main' - needs: build - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Pages - uses: actions/configure-pages@v3 - - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 0000000..aace797 --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,41 @@ +name: Publish documentation + +on: + push: + branches: [main] + workflow_dispatch: + + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + + build: + uses: ./.github/workflows/build_docs.yml + + deploy: + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Pages + uses: actions/configure-pages@v5 + + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/{{cookiecutter.repository_name}}/.github/workflows/build_docs.yml b/{{cookiecutter.repository_name}}/.github/workflows/build_docs.yml index 9ad42fe..093cedc 100644 --- a/{{cookiecutter.repository_name}}/.github/workflows/build_docs.yml +++ b/{{cookiecutter.repository_name}}/.github/workflows/build_docs.yml @@ -1,52 +1,36 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Build docs +name: Build documentation on: - workflow_dispatch: - workflow_call: pull_request: - branches: - - main + branches: [main] + workflow_call: + workflow_dispatch: + jobs: - build_docs: + + build: runs-on: ubuntu-22.04 env: - PYTHON_VERSION: "3.10" PUBLISH_DIR: ./_build/html + steps: - # checkout the repository - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v5 - # setup Python - - name: Install Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v4 + - name: Setup Python + uses: actions/setup-python@v6 with: - python-version: ${{ env.PYTHON_VERSION }} + python-version: "3.10" - # preserve pip cache to speed up installation - - name: Cache - id: cache - uses: actions/cache@v3 - with: - path: | - ~/.cache/pip - ~/_build - key: cache_v1 - restore-keys: | - cache_v1 - - - name: Install Python dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install ".[docs]" + - name: Install dependencies + run: python3 -m pip install ".[docs]" - name: Build docs - run: python3 -m jupyter book build . + run: jupyter-book build -W --keep-going . - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: - name: documentation path: ${{ env.PUBLISH_DIR }} diff --git a/{{cookiecutter.repository_name}}/.github/workflows/deploy_docs.yml b/{{cookiecutter.repository_name}}/.github/workflows/deploy_docs.yml index ebbaf27..aace797 100644 --- a/{{cookiecutter.repository_name}}/.github/workflows/deploy_docs.yml +++ b/{{cookiecutter.repository_name}}/.github/workflows/deploy_docs.yml @@ -1,51 +1,41 @@ -name: Github Pages +name: Publish documentation on: push: - branches: [main] # Only run on push to main + branches: [main] + workflow_dispatch: + -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow one concurrent deployment concurrency: group: "pages" cancel-in-progress: true jobs: - build-docs: + + build: uses: ./.github/workflows/build_docs.yml deploy: - needs: [build-docs] - + needs: build environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - steps: - - name: Download docs artifact - # docs artifact is uploaded by build-docs job - uses: actions/download-artifact@v3 - with: - name: documentation - path: "./public" - - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: "./public" + steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v5 + - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4