This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-website.git

commit dc1feff020309ef8622919f5b3a5de84fb028043
Author: Swatantra Yadav <[email protected]>
AuthorDate: Fri Oct 9 03:07:31 2026 +0530

    ci: build only affected documentation and preserve historical releases
    
    The current documentation build process rebuilds the entire website and
    all 26 historical NuttX releases (10.0.0 through 13.1.0) on every CI run,
    consuming 28 to 35 minutes of CI compute and exceeding Apache Foundation
    workflow resource guidelines.
    
    Optimize the documentation workflow to build incrementally:
    - In incremental mode (default on PRs, pushes, repository_dispatch, and
      daily cron), restore existing compiled release documentation directly
      from the asf-site branch via git archive in seconds.
    - Automatically detect and build any newly added release tags in NuttX
      that are not yet present in the documentation directory.
    - Always build master (latest docs) to keep online documentation in sync
      with the upstream repository.
    - Provide a full rebuild option via workflow_dispatch (build_all: true)
      and schedule a weekly full baseline rebuild on Sundays at 00:00 UTC
      using deterministic github.event.schedule event matching.
    - Guard git commit in publish.sh against clean working trees to prevent
      aborts when no changes need publishing.
    
    Fixes #124
    
    Signed-off-by: Swatantra Yadav <[email protected]>
---
 .github/workflows/main.yml | 75 +++++++++++++++++++++++++++++++++++++++++-----
 publish.sh                 |  6 +++-
 2 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9a4090a7ce..ea3271d801 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,15 +1,24 @@
 name: CI
 
-on:
+'on':
   repository_dispatch:
     types: docs
   workflow_dispatch:
+    inputs:
+      build_all:
+        description: 'Rebuild documentation for all historical releases'
+        required: false
+        default: false
+        type: boolean
   pull_request:
   push:
     branches:
       - master
   schedule:
-    - cron: '0 0 * * *'
+    # Full weekly rebuild on Sunday at 00:00 UTC
+    - cron: '0 0 * * 0'
+    # Daily incremental rebuild Monday through Saturday at 00:00 UTC
+    - cron: '0 0 * * 1-6'
 
 permissions:
   contents: write
@@ -54,19 +63,68 @@ jobs:
         sudo apt-get install -y plantuml
 
         echo "======================================================="
-        echo " Setup nuttx/Documentation"
+        echo " Setup docs directory"
+        echo "======================================================="
+        DOCDIR="$GITHUB_WORKSPACE/docs"
+        rm -rf "$DOCDIR"
+        mkdir -p "$DOCDIR"
+
+        # Determine whether to perform a full historical rebuild or an 
incremental build.
+        # - Full rebuild if workflow_dispatch input build_all is true.
+        # - Full rebuild on weekly scheduled run (Sunday: cron '0 0 * * 0').
+        # - Incremental build on PRs, pushes, repository_dispatch, and daily 
runs.
+        BUILD_ALL=false
+        if [ "${{ inputs.build_all }}" = "true" ]; then
+          echo " ==> Full rebuild requested via workflow input."
+          BUILD_ALL=true
+        elif [ "${{ github.event.schedule }}" = "0 0 * * 0" ]; then
+          echo " ==> Full weekly rebuild scheduled on Sunday."
+          BUILD_ALL=true
+        fi
+
+        # In incremental mode, restore existing compiled docs from the 
asf-site branch
+        if [ "$BUILD_ALL" != "true" ]; then
+          echo "======================================================="
+          echo " Restoring existing release docs from asf-site branch"
+          echo "======================================================="
+          git fetch origin asf-site --depth=1 || true
+          if git archive origin/asf-site content/docs 2>/dev/null | tar -x -C 
"$DOCDIR" --strip-components=2 2>/dev/null; then
+            echo " ==> Successfully restored existing release documentation."
+          else
+            echo "::warning::Could not restore docs from asf-site; falling 
back to full rebuild."
+            BUILD_ALL=true
+          fi
+        fi
+
+        echo "======================================================="
+        echo " Select Documentation versions to build"
         echo "======================================================="
         cd nuttx/Documentation
-        DOCDIR=../../docs
-        rm -rf $DOCDIR
 
         NUTTX_TAGS=$(git tag -l --sort=taggerdate 'nuttx-1?.*' | grep -Fv RC)
         export NUTTX_VERSIONS=$(echo -n "$NUTTX_TAGS" | sed -r 's|^nuttx-||g' 
| tr '\n' ',')
-        echo " ==> BUILD NUTTX DOCUMENTATION FOR: $NUTTX_VERSIONS (and 
master)."
 
-        for nuttx_version in $NUTTX_TAGS master; do
+        VERSIONS_TO_BUILD=""
+        if [ "$BUILD_ALL" = "true" ]; then
+          echo " ==> FULL REBUILD: building all historical releases and 
master."
+          VERSIONS_TO_BUILD="$NUTTX_TAGS master"
+        else
+          # Detect if any new release tags exist in NuttX that aren't yet in 
$DOCDIR
+          for tag in $NUTTX_TAGS; do
+            ver="${tag#nuttx-}"
+            if [ ! -d "$DOCDIR/$ver" ]; then
+              echo " ==> New release tag detected: $tag ($ver)"
+              VERSIONS_TO_BUILD="$VERSIONS_TO_BUILD $tag"
+            fi
+          done
+          # Always rebuild master (latest docs) to keep in sync with upstream
+          VERSIONS_TO_BUILD="$VERSIONS_TO_BUILD master"
+          echo " ==> INCREMENTAL BUILD: building $(echo $VERSIONS_TO_BUILD | 
xargs)."
+        fi
+
+        for nuttx_version in $VERSIONS_TO_BUILD; do
           echo " ===> BUILDING DOCUMENTATION FOR NuttX $nuttx_version."
-          git checkout -f $nuttx_version
+          git checkout -f "$nuttx_version"
 
           echo " ====> PIPENV INSTALL."
           pipenv install
@@ -77,6 +135,7 @@ jobs:
           else
             OUTDIR="$DOCDIR/${nuttx_version#nuttx-}"
           fi
+          rm -rf "$OUTDIR"
           echo " ====> OUTDIR IS: $OUTDIR."
 
           if pipenv run make html BUILDDIR="$OUTDIR"; then
diff --git a/publish.sh b/publish.sh
index 13e5435736..815c902512 100755
--- a/publish.sh
+++ b/publish.sh
@@ -42,7 +42,11 @@ git add content
 git status
 echo "Publishing website master branch $COMMIT_HASH_WEB"
 echo "Publishing docs from NuttX master branch $COMMIT_HASH_WEB"
-git commit -a -m "Publishing web: $COMMIT_HASH_WEB docs: $COMMIT_HASH_NUTTX"
+if git diff --staged --quiet; then
+  echo "No changes to commit or publish."
+else
+  git commit -a -m "Publishing web: $COMMIT_HASH_WEB docs: $COMMIT_HASH_NUTTX"
+fi
 echo " "
 echo "==================================================================="
 echo "You are now on the asf-site branch with your new changes committed."

Reply via email to