From 74ee9b885d6b6b1cd1aa4817d7c9553b78f30389 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 00:41:00 +0000 Subject: [PATCH 01/40] Update GitHub Actions workflows to use Python 3.8 and improve package installation steps --- .github/workflows/main.yml | 8 +++++--- .github/workflows/update_docs.yml | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e395dda..6e4f073 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,12 +16,14 @@ jobs: uses: actions/setup-python@v3 with: python-version: '3.8' - - run: conda config --append channels conda-forge - - run: python3 -m pip install -r requirements.txt + - run: | + conda config --append channels conda-forge + conda install -y python=3.8 + - run: python3.8 -m pip install -r requirements.txt - run: conda install -y pandoc==2.17 - run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - python3 -m pip install . + python3.8 -m pip install . - run: d2lbook build html diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index e475f88..1734b23 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -14,14 +14,15 @@ jobs: - uses: actions/checkout@v2 - uses: s-weigand/setup-conda@v1 - run: conda config --append channels conda-forge - - run: python3 -m pip install -r requirements.txt + - run: conda install -y python=3.8 + - run: python3.8 -m pip install -r requirements.txt - run: conda install -y pandoc==2.17 - run: pip install sphinx-mathjax-offline - run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - python3 -m pip install . + python3.8 -m pip install . - run: sh build_html.sh - run: cd .. - run: git clone https://github.com/openmlsys/html-en.git From 3200d0dae5f3756a893b1a2103bf5440f03d7e75 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 00:44:58 +0000 Subject: [PATCH 02/40] Refactor GitHub Actions workflows to streamline Conda channel configuration by removing defaults and ensuring conda-forge is prioritized for package installations. --- .github/workflows/main.yml | 1 + .github/workflows/update_docs.yml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6e4f073..2acae94 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,6 +18,7 @@ jobs: python-version: '3.8' - run: | conda config --append channels conda-forge + conda config --remove channels defaults conda install -y python=3.8 - run: python3.8 -m pip install -r requirements.txt - run: conda install -y pandoc==2.17 diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 1734b23..be9c12b 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -13,7 +13,9 @@ jobs: steps: - uses: actions/checkout@v2 - uses: s-weigand/setup-conda@v1 - - run: conda config --append channels conda-forge + - run: | + conda config --append channels conda-forge + conda config --remove channels defaults - run: conda install -y python=3.8 - run: python3.8 -m pip install -r requirements.txt - run: conda install -y pandoc==2.17 From d6aca2478ff702812a3e3c030ef2fd3aa3aa31fb Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 00:50:13 +0000 Subject: [PATCH 03/40] Refactor GitHub Actions workflows to enhance Conda environment setup and streamline package installation for D2l Test and Update Docs workflows. --- .github/workflows/main.yml | 29 +++++++++++++++-------------- .github/workflows/update_docs.yml | 14 +++++--------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2acae94..7cb3f5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,9 @@ -name: CI +name: D2l Test on: -- push -- pull_request -- workflow_dispatch # Allows you to run this workflow manually from the Actions tab + - push + - pull_request + - workflow_dispatch # Allows you to run this workflow manually from the Actions tab jobs: build: @@ -11,20 +11,21 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: s-weigand/setup-conda@v1 - - name: Set up Python 3.8 - uses: actions/setup-python@v3 - with: - python-version: '3.8' + name: Set up Conda environment + - run: | conda config --append channels conda-forge - conda config --remove channels defaults - conda install -y python=3.8 - - run: python3.8 -m pip install -r requirements.txt - - run: conda install -y pandoc==2.17 + conda create -n py38 python=3.8 -y # Create and activate Python 3.8 environment + conda activate py38 + conda install -y pandoc==2.17 + + - run: conda activate py38 && pip install -r requirements.txt - run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - python3.8 -m pip install . - - run: d2lbook build html + pip install . # Install the package from the cloned repo + + - run: d2lbook build html # Build HTML documentation diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index be9c12b..74b96c7 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,5 +1,4 @@ - -name: CI +name: Update Docs on: pull_request: @@ -15,10 +14,10 @@ jobs: - uses: s-weigand/setup-conda@v1 - run: | conda config --append channels conda-forge - conda config --remove channels defaults - - run: conda install -y python=3.8 - - run: python3.8 -m pip install -r requirements.txt - - run: conda install -y pandoc==2.17 + - run: conda create -n py38 python=3.8 -y + - run: conda activate py38 + - run: conda install -y -c conda-forge python=3.8 pandoc==2.17 + - run: pip install -r requirements.txt - run: pip install sphinx-mathjax-offline - run: | @@ -34,6 +33,3 @@ jobs: git add . git commit -m 'update english docs' git push - - - From f481622bc34132149ae6be57537e353e563e09ed Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 00:58:21 +0000 Subject: [PATCH 04/40] Refactor GitHub Actions workflows to improve Conda environment initialization and package installation steps, ensuring proper activation and configuration for Python 3.8 and pandoc. Update documentation build process to copy generated HTML files correctly. --- .github/workflows/main.yml | 9 ++++++--- .github/workflows/update_docs.yml | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cb3f5c..54ebe13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: D2l Test +name: CI on: - push @@ -18,11 +18,14 @@ jobs: - run: | conda config --append channels conda-forge conda create -n py38 python=3.8 -y # Create and activate Python 3.8 environment - conda activate py38 - conda install -y pandoc==2.17 + conda init bash # Initialize Conda for the bash shell + source ~/.bashrc # Source the updated bashrc to ensure 'conda activate' works + conda activate py38 # Activate the environment - run: conda activate py38 && pip install -r requirements.txt + - run: conda activate py38 && conda install -y pandoc==2.17 + - run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 74b96c7..dc882c2 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -9,25 +9,32 @@ jobs: if_merged: if: github.event.pull_request.merged == true runs-on: ubuntu-20.04 + steps: - uses: actions/checkout@v2 - uses: s-weigand/setup-conda@v1 + - run: | conda config --append channels conda-forge - - run: conda create -n py38 python=3.8 -y - - run: conda activate py38 - - run: conda install -y -c conda-forge python=3.8 pandoc==2.17 + conda init bash # Initialize Conda for the bash shell + source ~/.bashrc # Source the updated bashrc to ensure 'conda activate' works + conda create -n py38 python=3.8 -y # Create and activate Python 3.8 environment + conda activate py38 # Activate the environment + + - run: conda install -y -c conda-forge pandoc==2.17 # Install pandoc and other dependencies - run: pip install -r requirements.txt - run: pip install sphinx-mathjax-offline - run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - python3.8 -m pip install . - - run: sh build_html.sh + pip install . # Install the package from the cloned repo + - run: sh build_html.sh # Run the HTML build script + - run: cd .. - run: git clone https://github.com/openmlsys/html-en.git - - run: cp -r openmlsys-en/_build/html/* html-en/ + - run: cp -r d2l-book/_build/html/* html-en/ # Copy the built docs to the html-en repo + - run: | cd html-en git add . From d80b7e2ab4a448627896fb7fab6418f969a635db Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:05:30 +0000 Subject: [PATCH 05/40] Refactor GitHub Actions workflow to replace Conda setup with Python 3.8 virtual environment. Update dependency installation steps and streamline documentation build process for improved clarity and efficiency. --- .github/workflows/main.yml | 57 +++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54ebe13..d1126cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,34 +1,45 @@ name: CI on: - - push - - pull_request - - workflow_dispatch # Allows you to run this workflow manually from the Actions tab + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: # Allows you to run this workflow manually from the Actions tab jobs: build: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - - uses: s-weigand/setup-conda@v1 - name: Set up Conda environment - - - run: | - conda config --append channels conda-forge - conda create -n py38 python=3.8 -y # Create and activate Python 3.8 environment - conda init bash # Initialize Conda for the bash shell - source ~/.bashrc # Source the updated bashrc to ensure 'conda activate' works - conda activate py38 # Activate the environment - - - run: conda activate py38 && pip install -r requirements.txt - - - run: conda activate py38 && conda install -y pandoc==2.17 - - - run: | + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + + - name: Install pandoc + run: | + # Install pandoc using apt + sudo apt-get update + sudo apt-get install -y pandoc=2.17-1 + + - name: Clone and install d2l-book + run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - pip install . # Install the package from the cloned repo - - - run: d2lbook build html # Build HTML documentation + pip install . + + - name: Build HTML documentation + run: | + source venv/bin/activate + d2lbook build html From dcd3707c081a728e9d667e394eea7c0ba785df94 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:06:30 +0000 Subject: [PATCH 06/40] Refactor GitHub Actions workflow to simplify event triggers and maintain documentation build process. Consolidate push, pull_request, and workflow_dispatch events for improved clarity. --- .github/workflows/main.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1126cd..45aed88 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,9 @@ name: CI on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: # Allows you to run this workflow manually from the Actions tab + - push + - pull_request + - workflow_dispatch # Allows you to run this workflow manually from the Actions tab jobs: build: @@ -42,4 +40,4 @@ jobs: - name: Build HTML documentation run: | source venv/bin/activate - d2lbook build html + d2lbook build html \ No newline at end of file From c2be7088b2113608714c35a1274c92804458a1f6 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:08:15 +0000 Subject: [PATCH 07/40] Update GitHub Actions workflow to install the latest version of pandoc, removing the specific version constraint for improved compatibility and maintenance. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45aed88..4512006 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: run: | # Install pandoc using apt sudo apt-get update - sudo apt-get install -y pandoc=2.17-1 + sudo apt-get install -y pandoc - name: Clone and install d2l-book run: | From c43cca09a6c32946e519f3b7f34e5463a8e3610f Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:12:18 +0000 Subject: [PATCH 08/40] Update GitHub Actions workflow for D2l Test: rename workflow, add caching for Python packages, ensure specific version of pandoc is installed, and enforce installation of recommonmark dependency. --- .github/workflows/main.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4512006..4763dea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: CI +name: D2l Test on: - push @@ -18,18 +18,26 @@ jobs: with: python-version: '3.8' + - name: Cache Python packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies run: | python -m venv venv source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt + pip install recommonmark==0.7.1 # Ensure recommonmark is installed - name: Install pandoc run: | - # Install pandoc using apt sudo apt-get update - sudo apt-get install -y pandoc + sudo apt-get install -y pandoc=2.17-1 - name: Clone and install d2l-book run: | From ce84bd0cac231ce7821727f0f24ccc61e2dfba8b Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:14:34 +0000 Subject: [PATCH 09/40] Update GitHub Actions workflow to install the latest version of pandoc by removing the specific version constraint for improved compatibility. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4763dea..61fca71 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: - name: Install pandoc run: | sudo apt-get update - sudo apt-get install -y pandoc=2.17-1 + sudo apt-get install -y pandoc - name: Clone and install d2l-book run: | From 1dcfa5319b392e0d746cf44f81c3996b616f10bb Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:19:01 +0000 Subject: [PATCH 10/40] Update GitHub Actions workflow to install sphinxcontrib-bibtex dependency alongside recommonmark for enhanced documentation generation. --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61fca71..2664eb5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,8 @@ jobs: source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt - pip install recommonmark==0.7.1 # Ensure recommonmark is installed + pip install recommonmark==0.7.1 + pip install sphinxcontrib-bibtex==2.4.0 - name: Install pandoc run: | From ae920644ec2c97281f09dd44b8b2734b361bf898 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:22:40 +0000 Subject: [PATCH 11/40] Refactor GitHub Actions workflow to remove specific version installations of recommonmark and sphinxcontrib-bibtex, enhancing flexibility in dependency management. Ensure virtual environment is activated before package installations for improved reliability. --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2664eb5..2073046 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,8 +32,6 @@ jobs: source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt - pip install recommonmark==0.7.1 - pip install sphinxcontrib-bibtex==2.4.0 - name: Install pandoc run: | @@ -44,6 +42,7 @@ jobs: run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book + source venv/bin/activate pip install . - name: Build HTML documentation From b0c7cb8b210f3f5d4ba3246aca0390c640efa949 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:26:14 +0000 Subject: [PATCH 12/40] Refactor GitHub Actions workflow to streamline the installation process by moving the d2l-book cloning and installation steps to occur after the virtual environment activation. This change enhances the clarity and reliability of the setup process. --- .github/workflows/main.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2073046..6921ed4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,19 +32,16 @@ jobs: source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt - + cd .. + git clone https://github.com/openmlsys/d2l-book.git + cd d2l-book + pip install . + - name: Install pandoc run: | sudo apt-get update sudo apt-get install -y pandoc - - name: Clone and install d2l-book - run: | - git clone https://github.com/openmlsys/d2l-book.git - cd d2l-book - source venv/bin/activate - pip install . - - name: Build HTML documentation run: | source venv/bin/activate From b4285276c218209b41249a12fe223bc0ea6547b9 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:33:19 +0000 Subject: [PATCH 13/40] Refactor GitHub Actions workflow to enhance documentation build process by replacing Conda setup with a Python 3.8 virtual environment. Introduce caching for Python packages, streamline dependency installation, and ensure proper cloning and installation of the d2l-book repository. Improve commit and push logic for updated documentation, ensuring changes are only committed if there are modifications. --- .github/workflows/update_docs.yml | 80 +++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index dc882c2..17dab09 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -11,32 +11,72 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - uses: s-weigand/setup-conda@v1 + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v2 - - run: | - conda config --append channels conda-forge - conda init bash # Initialize Conda for the bash shell - source ~/.bashrc # Source the updated bashrc to ensure 'conda activate' works - conda create -n py38 python=3.8 -y # Create and activate Python 3.8 environment - conda activate py38 # Activate the environment + # Set up Python 3.8 + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: '3.8' - - run: conda install -y -c conda-forge pandoc==2.17 # Install pandoc and other dependencies - - run: pip install -r requirements.txt - - run: pip install sphinx-mathjax-offline + # Cache Python packages to speed up builds + - name: Cache Python packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - - run: | + # Install Python dependencies + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + pip install sphinx-mathjax-offline + + # Install Pandoc using apt-get + - name: Install Pandoc + run: | + sudo apt-get update + sudo apt-get install -y pandoc + + # Clone and install the d2l-book repository + - name: Clone and install d2l-book + run: | git clone https://github.com/openmlsys/d2l-book.git cd d2l-book - pip install . # Install the package from the cloned repo - - run: sh build_html.sh # Run the HTML build script + pip install . + + # Build the HTML documentation + - name: Build HTML Documentation + run: | + source ../venv/bin/activate + sh build_html.sh + + # Clone the html-en repository + - name: Clone html-en Repository + run: | + cd .. + git clone https://github.com/openmlsys/html-en.git - - run: cd .. - - run: git clone https://github.com/openmlsys/html-en.git - - run: cp -r d2l-book/_build/html/* html-en/ # Copy the built docs to the html-en repo + # Copy the built HTML docs to html-en + - name: Copy Built Docs to html-en + run: | + cp -r d2l-book/_build/html/* html-en/ - - run: | + # Commit and push the updated docs + - name: Commit and Push Changes + run: | cd html-en + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m 'update english docs' - git push + # Commit only if there are changes + git diff --quiet || git commit -m 'Update English docs' + # Push changes if there are any + git push || echo "No changes to push" From 46f56b81ba0587cc52f5892b3b27151f72298acd Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:34:19 +0000 Subject: [PATCH 14/40] Enhance GitHub Actions workflow by adding push event trigger for the main branch and ensuring pull request events are limited to the main branch. This improves the clarity of event handling for documentation updates. --- .github/workflows/update_docs.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 17dab09..56b3610 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,9 +1,14 @@ name: Update Docs on: + push: + branches: + - main pull_request: types: - closed + branches: + - main jobs: if_merged: From 7ebf6b7b368a0012a6224354c9c5fc754369e26e Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:37:54 +0000 Subject: [PATCH 15/40] Refactor GitHub Actions workflow to simplify event triggers by consolidating push and pull_request events, and adding workflow_dispatch for manual execution. This enhances the clarity and flexibility of the documentation update process. --- .github/workflows/update_docs.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 56b3610..e45df9c 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,14 +1,10 @@ name: Update Docs on: - push: - branches: - - main - pull_request: - types: - - closed - branches: - - main + - push + - pull_request + - workflow_dispatch # Allows you to run this workflow manually from the Actions tab + jobs: if_merged: From 196b77c72c06cba7d6a9d1b39eb1769e79824a6e Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:44:23 +0000 Subject: [PATCH 16/40] Refactor GitHub Actions workflow to simplify event triggers by consolidating push, pull_request, and adding workflow_dispatch for manual execution. This enhances clarity and flexibility in the documentation update process. --- .github/workflows/update_docs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index e45df9c..1715617 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -7,8 +7,7 @@ on: jobs: - if_merged: - if: github.event.pull_request.merged == true + build: runs-on: ubuntu-20.04 steps: From c3889b24d5c9bfc93cc4eac484fb4efefa25501f Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 01:51:07 +0000 Subject: [PATCH 17/40] Refactor GitHub Actions workflow to streamline the installation and documentation build process. Consolidate Python dependency installation and d2l-book setup into a single step, ensuring the virtual environment is activated beforehand. Update the copying of built HTML documentation to improve clarity and efficiency. --- .github/workflows/update_docs.yml | 32 ++++++++++--------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index e7a2355..0282423 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -29,44 +29,32 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - # Install Python dependencies - - name: Install dependencies - run: | - python -m venv venv - source venv/bin/activate - pip install --upgrade pip - pip install -r requirements.txt - pip install sphinx-mathjax-offline # Install Pandoc using apt-get - name: Install Pandoc run: | sudo apt-get update sudo apt-get install -y pandoc - - # Clone and install the d2l-book repository - - name: Clone and install d2l-book + + # Install Python dependencies and build the HTML documentation + - name: Install dependencies run: | + python -m venv venv + source venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + pip install sphinx-mathjax-offline git clone https://github.com/openmlsys/d2l-book.git cd d2l-book pip install . - - # Build the HTML documentation - - name: Build HTML Documentation - run: | - source ../venv/bin/activate + cd .. sh build_html.sh # Clone the html-en repository - name: Clone html-en Repository run: | - cd .. git clone https://github.com/openmlsys/html-en.git - - # Copy the built HTML docs to html-en - - name: Copy Built Docs to html-en - run: | - cp -r d2l-book/_build/html/* html-en/ + cp -r _build/html/* html-en/ # Commit and push the updated docs - name: Commit and Push Changes From 8f06cb13fc63b21a7717c997d98782d0e8538b83 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 16:21:10 +0000 Subject: [PATCH 18/40] Add D2l Test workflow for automated documentation build - Introduced a new GitHub Actions workflow for D2l Test that triggers on push, pull_request, and manual execution. - Set up Python 3.8 environment and caching for Python packages to optimize dependency installation. - Streamlined the installation process for d2l-book and added steps to install pandoc. - Enhanced the documentation build process by ensuring proper activation of the virtual environment before building HTML documentation. --- .github/workflows/{main.yml => .main.yml.test} | 0 .github/workflows/update_docs.yml | 8 +------- 2 files changed, 1 insertion(+), 7 deletions(-) rename .github/workflows/{main.yml => .main.yml.test} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/.main.yml.test similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/.main.yml.test diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 0282423..3792b18 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -54,16 +54,10 @@ jobs: - name: Clone html-en Repository run: | git clone https://github.com/openmlsys/html-en.git - cp -r _build/html/* html-en/ - - # Commit and push the updated docs - - name: Commit and Push Changes - run: | + cp -rf _build/html/* html-en/ cd html-en git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . - # Commit only if there are changes git diff --quiet || git commit -m 'Update English docs' - # Push changes if there are any git push || echo "No changes to push" From e76edc6d89665e4765e516440da6def79ae4fbe5 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 16:42:06 +0000 Subject: [PATCH 19/40] Refactor GitHub Actions workflow for documentation updates: streamline cloning and copying of HTML files, improve commit logic to ensure documentation is only updated when changes are present. --- .github/workflows/update_docs.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 3792b18..163be41 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -51,13 +51,11 @@ jobs: sh build_html.sh # Clone the html-en repository - - name: Clone html-en Repository - run: | - git clone https://github.com/openmlsys/html-en.git - cp -rf _build/html/* html-en/ - cd html-en - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" + - run: cd .. + - run: git clone https://github.com/openmlsys/html-en.git + - run: cp -r _build/html/* html-en/ + - run: | + cd html-en git add . - git diff --quiet || git commit -m 'Update English docs' - git push || echo "No changes to push" + git commit -m 'update docs' + git push \ No newline at end of file From da2b4cf63ff5a60cdcaa041b14aae9425f599b85 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 16:46:27 +0000 Subject: [PATCH 20/40] Update GitHub Actions workflow for documentation updates: configure Git user details for automated commits and adjust push command to ensure proper branch tracking. --- .github/workflows/update_docs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 163be41..72d69eb 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -57,5 +57,7 @@ jobs: - run: | cd html-en git add . + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m 'update docs' - git push \ No newline at end of file + git push -u origin master \ No newline at end of file From cbd7c645a676c0377bdd0a7dd595d52891ffdd40 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 16:54:37 +0000 Subject: [PATCH 21/40] Update GitHub Actions workflow to change default branch from 'master' to 'main' for documentation updates, ensuring proper branch tracking during automated commits. --- .github/workflows/update_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 72d69eb..2294582 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -60,4 +60,4 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m 'update docs' - git push -u origin master \ No newline at end of file + git push -u origin main \ No newline at end of file From 80c39d296c9a1894689d067933bb8373fc157abd Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 16:59:41 +0000 Subject: [PATCH 22/40] Update GitHub Actions workflow to change commit author details for documentation updates, replacing the default GitHub Actions bot with specific user information. --- .github/workflows/update_docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 2294582..edc31f5 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -57,7 +57,7 @@ jobs: - run: | cd html-en git add . - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "Chivier" + git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' git push -u origin main \ No newline at end of file From c1a6e788f88b5b206e4b4911168100f0091647c7 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Sat, 18 Jan 2025 17:10:17 +0000 Subject: [PATCH 23/40] Update GitHub Actions workflow to use GitHub token for cloning and pushing documentation updates, enhancing security and ensuring proper authentication during automated commits. --- .github/workflows/update_docs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index edc31f5..dd504dc 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -52,7 +52,8 @@ jobs: # Clone the html-en repository - run: cd .. - - run: git clone https://github.com/openmlsys/html-en.git + - run: | + git clone https://${{ secrets.GITHUB_TOKEN }}@github.com/openmlsys/html-en.git - run: cp -r _build/html/* html-en/ - run: | cd html-en @@ -60,4 +61,4 @@ jobs: git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push -u origin main \ No newline at end of file + git push -u https://${{ secrets.GITHUB_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file From 0d58d5f728300090bef12b532727d2771080fe67 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:16:16 +0000 Subject: [PATCH 24/40] Simplify GitHub Actions workflow for documentation updates - Remove Python package caching step - Streamline workflow steps by removing redundant names - Modify GitHub token usage for cloning and pushing documentation - Improve overall workflow readability and efficiency --- .github/workflows/update_docs.yml | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index dd504dc..7e21a86 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -11,34 +11,20 @@ jobs: steps: # Checkout the repository - - name: Checkout repository - uses: actions/checkout@v2 + - uses: actions/checkout@v2 # Set up Python 3.8 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: '3.8' - # Cache Python packages to speed up builds - - name: Cache Python packages - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - # Install Pandoc using apt-get - - name: Install Pandoc - run: | + - run: | sudo apt-get update sudo apt-get install -y pandoc # Install Python dependencies and build the HTML documentation - - name: Install dependencies - run: | + - run: | python -m venv venv source venv/bin/activate pip install --upgrade pip @@ -53,7 +39,7 @@ jobs: # Clone the html-en repository - run: cd .. - run: | - git clone https://${{ secrets.GITHUB_TOKEN }}@github.com/openmlsys/html-en.git + git clone https://github.com/openmlsys/html-en.git - run: cp -r _build/html/* html-en/ - run: | cd html-en @@ -61,4 +47,4 @@ jobs: git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push -u https://${{ secrets.GITHUB_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file + git push -u https://github.com/openmlsys/html-en.git main From c68270499619cf65a948ff336c74de58af9da5bc Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:21:56 +0000 Subject: [PATCH 25/40] Fix GitHub Actions documentation update workflow push command - Remove hardcoded repository URL from git push command - Simplify push operation to use default remote repository --- .github/workflows/update_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 7e21a86..236aa5e 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -47,4 +47,4 @@ jobs: git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push -u https://github.com/openmlsys/html-en.git main + git push From 6538edf71cfcafaf2311f254227d2a2d97707f3c Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:24:13 +0000 Subject: [PATCH 26/40] Remove hardcoded Git user configuration in documentation update workflow --- .github/workflows/update_docs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 236aa5e..122627f 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -44,7 +44,5 @@ jobs: - run: | cd html-en git add . - git config user.name "Chivier" - git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' git push From aeed6e5bdb9948d90fee924c53da5f278b39e6e1 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:27:13 +0000 Subject: [PATCH 27/40] Add explicit Git user configuration in documentation update workflow - Configure Git user name and email before committing - Ensure proper user attribution for automated documentation updates --- .github/workflows/update_docs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 122627f..1a2af3e 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -44,5 +44,7 @@ jobs: - run: | cd html-en git add . + git config user.name "Chivier" + git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push + git push -u origin main From 3caad957d0849b1528cd8ea4e3ec16644ddcba25 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:46:19 +0000 Subject: [PATCH 28/40] Add PAT token environment variable to documentation update workflow - Include PAT_TOKEN as an environment variable in the GitHub Actions workflow - Prepare for potential authentication or access requirements in the documentation update process --- .github/workflows/update_docs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 1a2af3e..23b662b 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -18,6 +18,8 @@ jobs: with: python-version: '3.8' + - env: + PAT_TOKEN: ${{ secrets.PAT_TOKEN }} # Install Pandoc using apt-get - run: | sudo apt-get update @@ -47,4 +49,4 @@ jobs: git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push -u origin main + git push https://$PAT_TOKEN@github.com/openmlsys/html-en.git HEAD:main From e19fba58317f03b3146ce445d89ae4456eb8859b Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 14:49:24 +0000 Subject: [PATCH 29/40] Refactor documentation update workflow PAT token placement - Move PAT_TOKEN environment variable to the appropriate step - Ensure correct environment variable scoping for Git push operation --- .github/workflows/update_docs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 05dc321..04e4754 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -18,8 +18,7 @@ jobs: with: python-version: '3.8' - - env: - PAT_TOKEN: ${{ secrets.PAT_TOKEN }} + # Install Pandoc using apt-get - run: | sudo apt-get update @@ -43,11 +42,12 @@ jobs: - run: | git clone https://github.com/openmlsys/html-en.git - run: cp -r _build/html/* html-en/ - - run: | + - env: + PAT_TOKEN: ${{ secrets.PAT_TOKEN }} + run: | cd html-en git add . git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' git push https://$PAT_TOKEN@github.com/openmlsys/html-en.git HEAD:main - From 83008334be6e89a624d1437210e2d461a3c2bb78 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 15:22:18 +0000 Subject: [PATCH 30/40] Refactor documentation update workflow authentication and push mechanism - Update Git remote URL configuration to use GitHub token - Simplify authentication and push process for documentation updates - Remove redundant environment variable and push command --- .github/workflows/update_docs.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 04e4754..195e46b 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,30 +1,23 @@ name: Update Docs - on: - push - pull_request - - workflow_dispatch - + - workflow_dispatch jobs: build: runs-on: ubuntu-20.04 - steps: # Checkout the repository - uses: actions/checkout@v2 - # Set up Python 3.8 - uses: actions/setup-python@v4 with: python-version: '3.8' - - - # Install Pandoc using apt-get + # Install Pandoc - run: | sudo apt-get update sudo apt-get install -y pandoc - - # Install Python dependencies and build the HTML documentation + # Install dependencies and build docs - run: | python -m venv venv source venv/bin/activate @@ -36,18 +29,17 @@ jobs: pip install . cd .. sh build_html.sh - - # Clone the html-en repository + # Clone html-en and push updates with PAT auth - run: cd .. - run: | git clone https://github.com/openmlsys/html-en.git - run: cp -r _build/html/* html-en/ - - env: - PAT_TOKEN: ${{ secrets.PAT_TOKEN }} - run: | - cd html-en + - run: | + cd html-en + # Authenticate with PAT before pushing + git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git git add . git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git commit -m 'update docs' - git push https://$PAT_TOKEN@github.com/openmlsys/html-en.git HEAD:main + git push origin main \ No newline at end of file From dbe7566d57bc5685695adadea73b5e2de5bfb087 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 15:32:07 +0000 Subject: [PATCH 31/40] Streamline documentation update workflow authentication - Use PAT token directly in Git clone and push commands - Remove redundant remote URL configuration steps - Simplify authentication mechanism for documentation updates --- .github/workflows/update_docs.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 195e46b..ab6322a 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -7,17 +7,13 @@ jobs: build: runs-on: ubuntu-20.04 steps: - # Checkout the repository - uses: actions/checkout@v2 - # Set up Python 3.8 - uses: actions/setup-python@v4 with: python-version: '3.8' - # Install Pandoc - run: | sudo apt-get update sudo apt-get install -y pandoc - # Install dependencies and build docs - run: | python -m venv venv source venv/bin/activate @@ -29,17 +25,14 @@ jobs: pip install . cd .. sh build_html.sh - # Clone html-en and push updates with PAT auth - run: cd .. - run: | - git clone https://github.com/openmlsys/html-en.git + git clone https://${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git - run: cp -r _build/html/* html-en/ - run: | cd html-en - # Authenticate with PAT before pushing - git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git - git add . git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" + git add . git commit -m 'update docs' - git push origin main \ No newline at end of file + git push https://${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file From 8940abd4f68e19e0c8c7835999f82846891d11eb Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 15:34:49 +0000 Subject: [PATCH 32/40] Improve GitHub Actions documentation update workflow authentication - Use 'x-access-token:' prefix for PAT token authentication - Consolidate clone and push steps into a single named step - Enhance security and clarity of Git authentication process --- .github/workflows/update_docs.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index ab6322a..3e79b91 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -26,13 +26,14 @@ jobs: cd .. sh build_html.sh - run: cd .. - - run: | - git clone https://${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git - - run: cp -r _build/html/* html-en/ - - run: | + # Modified these steps for proper authentication + - name: Clone and push to html-en + run: | + git clone https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git + cp -r _build/html/* html-en/ cd html-en git config user.name "Chivier" git config user.email "chivier.humber@outlook.com" git add . git commit -m 'update docs' - git push https://${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file + git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file From 032f95ce8a50d1d7e781a78f048dba319bf94b4a Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 15:40:50 +0000 Subject: [PATCH 33/40] Update GitHub Actions documentation workflow authentication - Replace PAT_TOKEN with GH_TOKEN for authentication - Update Git user configuration to use GitHub Actions Bot identity - Simplify authentication and user configuration for documentation updates --- .github/workflows/update_docs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 3e79b91..c2054a4 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -29,11 +29,11 @@ jobs: # Modified these steps for proper authentication - name: Clone and push to html-en run: | - git clone https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git + git clone https://${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git cp -r _build/html/* html-en/ cd html-en - git config user.name "Chivier" - git config user.email "chivier.humber@outlook.com" + git config user.name 'GitHub Actions Bot' + git config user.email 'github-actions[bot]@users.noreply.github.com' git add . git commit -m 'update docs' - git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file + git push https://${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file From 759287a94c3b7eab1f2e699f5b38fcbce45d9640 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 16:24:50 +0000 Subject: [PATCH 34/40] Refactor and enhance documentation update GitHub Actions workflow - Update workflow to use more robust and secure configuration - Add environment variables for better maintainability - Improve Python dependency and build process - Enhance deployment logic with conditional checks and detailed commit messages - Update to latest GitHub Actions checkout and setup actions --- .github/workflows/update_docs.yml | 96 +++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 18 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index c2054a4..c7c1094 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,39 +1,99 @@ name: Update Docs + on: - - push - - pull_request - - workflow_dispatch + push: + branches: + - main # specify branches if needed + pull_request: + workflow_dispatch: + +env: + PYTHON_VERSION: '3.8' + DEST_REPO: 'openmlsys/html-en' + GIT_USER_NAME: 'GitHub Actions Bot' + GIT_USER_EMAIL: 'github-actions[bot]@users.noreply.github.com' + jobs: - build: + build-and-deploy: runs-on: ubuntu-20.04 + steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - name: Checkout repository + uses: actions/checkout@v3 # Updated to v3 with: - python-version: '3.8' - - run: | + fetch-depth: 0 # Fetch all history for better versioning + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' # Enable pip caching + + - name: Install system dependencies + run: | sudo apt-get update sudo apt-get install -y pandoc - - run: | + + - name: Setup Python virtual environment + run: | python -m venv venv source venv/bin/activate pip install --upgrade pip + + - name: Install Python dependencies + run: | + source venv/bin/activate pip install -r requirements.txt pip install sphinx-mathjax-offline + + - name: Install d2l-book + run: | + source venv/bin/activate git clone https://github.com/openmlsys/d2l-book.git cd d2l-book pip install . cd .. + + - name: Build documentation + run: | + source venv/bin/activate sh build_html.sh - - run: cd .. - # Modified these steps for proper authentication - - name: Clone and push to html-en + + - name: Deploy to html-en repository + if: github.event_name != 'pull_request' # Don't deploy on PRs + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | - git clone https://${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git + # Clone the destination repository + git clone https://${GH_TOKEN}@github.com/${DEST_REPO}.git + + # Copy built documentation cp -r _build/html/* html-en/ + + # Configure git cd html-en - git config user.name 'GitHub Actions Bot' - git config user.email 'github-actions[bot]@users.noreply.github.com' - git add . - git commit -m 'update docs' - git push https://${{ secrets.GH_TOKEN }}@github.com/openmlsys/html-en.git main \ No newline at end of file + git config user.name "${GIT_USER_NAME}" + git config user.email "${GIT_USER_EMAIL}" + + # Check if there are changes to commit + if [[ -n $(git status -s) ]]; then + git add . + git commit -m "docs: update documentation + + Automated update by GitHub Actions + Workflow: ${{ github.workflow }} + Run ID: ${{ github.run_id }} + Triggered by: ${{ github.event_name }}" + + # Push changes + git push origin main + else + echo "No changes to commit" + fi + + - name: Clean up + if: always() + run: | + rm -rf venv + rm -rf html-en + rm -rf d2l-book From 64fedbcb64fd0ffbf131c7ca5f4bfc454e6ed375 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 16:34:24 +0000 Subject: [PATCH 35/40] Simplify GitHub Actions documentation update workflow trigger conditions - Remove branch-specific push trigger - Remove conditional deployment check - Streamline workflow configuration for more flexible execution --- .github/workflows/update_docs.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index c7c1094..4774d8f 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -2,10 +2,8 @@ name: Update Docs on: push: - branches: - - main # specify branches if needed pull_request: - workflow_dispatch: + workflow_dispatch env: PYTHON_VERSION: '3.8' @@ -60,7 +58,6 @@ jobs: sh build_html.sh - name: Deploy to html-en repository - if: github.event_name != 'pull_request' # Don't deploy on PRs env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | From 02b57101c1943c452bd7d834bdc513af9f706f79 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 16:40:42 +0000 Subject: [PATCH 36/40] Minor formatting adjustment in GitHub Actions documentation update workflow - Add trailing comma to workflow_dispatch trigger - Improve YAML formatting consistency --- .github/workflows/update_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 4774d8f..e588f40 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -3,7 +3,7 @@ name: Update Docs on: push: pull_request: - workflow_dispatch + workflow_dispatch: env: PYTHON_VERSION: '3.8' From bad5bcb5e5f4516a6549683a1e93ab7fa6e05bce Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 16:50:13 +0000 Subject: [PATCH 37/40] Refactor GitHub Actions documentation update workflow to use Git worktree for pages branch deployment - Replace hardcoded destination repository with in-repository pages branch deployment - Use git worktree to manage pages branch checkout and updates - Simplify documentation deployment process by removing external repository clone - Improve workflow clarity and reduce complexity of documentation publishing --- .github/workflows/update_docs.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index e588f40..d6f7adb 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -7,7 +7,6 @@ on: env: PYTHON_VERSION: '3.8' - DEST_REPO: 'openmlsys/html-en' GIT_USER_NAME: 'GitHub Actions Bot' GIT_USER_EMAIL: 'github-actions[bot]@users.noreply.github.com' @@ -57,18 +56,20 @@ jobs: source venv/bin/activate sh build_html.sh - - name: Deploy to html-en repository - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + - name: Deploy to pages branch run: | - # Clone the destination repository - git clone https://${GH_TOKEN}@github.com/${DEST_REPO}.git + # Create and switch to a new worktree for the pages branch + git worktree add --detach pages + cd pages + git checkout pages || git checkout --orphan pages + + # Remove existing files to prepare for new content + git rm -rf . || true # Copy built documentation - cp -r _build/html/* html-en/ + cp -r ../_build/html/* . # Configure git - cd html-en git config user.name "${GIT_USER_NAME}" git config user.email "${GIT_USER_EMAIL}" @@ -82,15 +83,18 @@ jobs: Run ID: ${{ github.run_id }} Triggered by: ${{ github.event_name }}" - # Push changes - git push origin main + # Push changes to pages branch + git push origin pages else echo "No changes to commit" fi + + # Clean up the worktree + cd .. + git worktree remove pages - name: Clean up if: always() run: | rm -rf venv - rm -rf html-en rm -rf d2l-book From 9039db66a7b836ba36823d086efab69ccfa7a761 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 17:18:14 +0000 Subject: [PATCH 38/40] Enhance Git worktree handling in documentation update workflow - Improve pages branch checkout and update logic - Add explicit fetch and pull for the pages branch - Ensure robust handling of existing and new pages branches --- .github/workflows/update_docs.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index d6f7adb..51c452d 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -61,8 +61,16 @@ jobs: # Create and switch to a new worktree for the pages branch git worktree add --detach pages cd pages + + # Fetch and checkout pages branch, create if it doesn't exist + git fetch origin pages || true git checkout pages || git checkout --orphan pages + # If the branch exists, pull latest changes + if git rev-parse --verify origin/pages >/dev/null 2>&1; then + git pull origin pages + fi + # Remove existing files to prepare for new content git rm -rf . || true From ed8ba94f1581c5bb5f0c1774cf96b0d4ce8683c7 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 17:21:39 +0000 Subject: [PATCH 39/40] Simplify documentation update workflow branch handling - Modify pages branch deployment to use force push - Remove complex branch existence and update checks - Streamline Git worktree and branch management logic - Ensure consistent documentation deployment process --- .github/workflows/update_docs.yml | 39 +++++++++++-------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 51c452d..e37a47c 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -55,23 +55,16 @@ jobs: run: | source venv/bin/activate sh build_html.sh - - name: Deploy to pages branch run: | # Create and switch to a new worktree for the pages branch git worktree add --detach pages cd pages - # Fetch and checkout pages branch, create if it doesn't exist + # Delete pages branch if it exists and create a new orphan branch git fetch origin pages || true - git checkout pages || git checkout --orphan pages - - # If the branch exists, pull latest changes - if git rev-parse --verify origin/pages >/dev/null 2>&1; then - git pull origin pages - fi - - # Remove existing files to prepare for new content + git branch -D pages || true + git checkout --orphan pages git rm -rf . || true # Copy built documentation @@ -81,21 +74,17 @@ jobs: git config user.name "${GIT_USER_NAME}" git config user.email "${GIT_USER_EMAIL}" - # Check if there are changes to commit - if [[ -n $(git status -s) ]]; then - git add . - git commit -m "docs: update documentation - - Automated update by GitHub Actions - Workflow: ${{ github.workflow }} - Run ID: ${{ github.run_id }} - Triggered by: ${{ github.event_name }}" - - # Push changes to pages branch - git push origin pages - else - echo "No changes to commit" - fi + # Add and commit all changes + git add . + git commit -m "docs: update documentation + + Automated update by GitHub Actions + Workflow: ${{ github.workflow }} + Run ID: ${{ github.run_id }} + Triggered by: ${{ github.event_name }}" + + # Force push to pages branch + git push -f origin pages # Clean up the worktree cd .. From 4acbe6a7585f34b30f9d325a1f00f3a0c56aa822 Mon Sep 17 00:00:00 2001 From: Chivier Humber Date: Mon, 27 Jan 2025 17:59:25 +0000 Subject: [PATCH 40/40] update structure --- .github/workflows/update_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index e37a47c..48a763a 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -68,7 +68,7 @@ jobs: git rm -rf . || true # Copy built documentation - cp -r ../_build/html/* . + cp -r ../_build/html . # Configure git git config user.name "${GIT_USER_NAME}"