From e6878691c6c912d5f62afc7f180bea6c75da2b64 Mon Sep 17 00:00:00 2001 From: maxsibilla Date: Tue, 9 Dec 2025 15:09:40 -0500 Subject: [PATCH 1/5] Updating check for changes in the code --- .github/workflows/build-search.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-search.yaml b/.github/workflows/build-search.yaml index 54d2407..0ddc52e 100644 --- a/.github/workflows/build-search.yaml +++ b/.github/workflows/build-search.yaml @@ -36,10 +36,10 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '20' - name: Install dependencies - run: npm ci + run: npm ci - name: Build search run: npm run search @@ -48,8 +48,7 @@ jobs: - name: Check for changes id: check_changes run: | - git diff --exit-code - if [ $? -eq 0 ]; then + if git diff --exit-code; then echo "No changes to commit." echo "::set-output name=changes::false" else From b5ec91cda5cee98975817b28f0d25628c84fcfcc Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Wed, 10 Dec 2025 08:42:57 -0500 Subject: [PATCH 2/5] Update github action --- .github/workflows/build-search.yaml | 34 +++++++++++------------------ gulpfile.js | 14 +++++------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-search.yaml b/.github/workflows/build-search.yaml index 0ddc52e..783fd4d 100644 --- a/.github/workflows/build-search.yaml +++ b/.github/workflows/build-search.yaml @@ -1,4 +1,4 @@ -name: build-search-indices +name: Build Search Indicies on: pull_request: @@ -19,47 +19,39 @@ concurrency: group: "pages" cancel-in-progress: false - jobs: buildSearch: runs-on: ubuntu-latest + if: ${{ ! contains(github.event.head_commit.message, 'Automate update') }} steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v4 # Uses the private access token from above link with: + fetch-depth: 0 token: ${{ secrets.GH_SUBMODULE_SECRET }} - - name: Pull latest changes - run: git pull origin main + - name: Print the actors name + run: echo "The workflow was initiated by ${{ github.actor }}" + + - name: Restore timestamps + uses: chetan/git-restore-mtime-action@v1 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '20' - name: Install dependencies - run: npm ci + run: npm ci - name: Build search run: npm run search - # Check if there are any changes before attempting to commit and push changes - - name: Check for changes - id: check_changes - run: | - if git diff --exit-code; then - echo "No changes to commit." - echo "::set-output name=changes::false" - else - echo "::set-output name=changes::true" - fi - - name: Commit & push changes run: | git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions - build search index" git status git add . - git commit -m "Update site-search-data.json" - git push origin main + git commit -m "Automate update site-search-data.json" + git push origin main \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 9e39c0e..a6c835a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -146,7 +146,7 @@ function createIndex(path, statsSync) { if (h.textContent != 'Table of Contents' && !searchDict[title+urlPath]) { content += `{ "title": "${title}", - "mod": "${statsSync.mtime}", + "mod": "${statsSync.trim()}", "tag": "${tag}", "tagId": "${h.getAttribute('id')}", "path": "/${urlPath.replace('.md', '.html')}" @@ -161,7 +161,7 @@ function createIndex(path, statsSync) { } catch(e) { console.error('Index error: ', path, e) } - }); + }); } function getAllFilesRecursively(directoryPath) { @@ -183,16 +183,14 @@ function getAllFilesRecursively(directoryPath) { for (let f of filePaths) { if ( f.indexOf('.html') > -1 || f.indexOf('.md') > -1 ) { - let statsSync = {} try { - statsSync = fs.statSync(f) + exec('git log -1 --format="%ad" -- '+f, (error, stdout, stderr) => { + createIndex(f, stdout) + }) } catch (err) { console.error('Error getting file stats synchronously:', err); - } - - createIndex(f, statsSync) - + } } } From 66ca1e7b1d49d98a7df32032c93ca81561df9696 Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Wed, 10 Dec 2025 08:44:38 -0500 Subject: [PATCH 3/5] Remove print name step --- .github/workflows/build-search.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-search.yaml b/.github/workflows/build-search.yaml index 783fd4d..98f9931 100644 --- a/.github/workflows/build-search.yaml +++ b/.github/workflows/build-search.yaml @@ -30,9 +30,6 @@ jobs: fetch-depth: 0 token: ${{ secrets.GH_SUBMODULE_SECRET }} - - name: Print the actors name - run: echo "The workflow was initiated by ${{ github.actor }}" - - name: Restore timestamps uses: chetan/git-restore-mtime-action@v1 From 043a47804f3585f4691d89338cbbe27515f2c3f0 Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Wed, 10 Dec 2025 09:08:15 -0500 Subject: [PATCH 4/5] Replenish name change --- .github/workflows/build-search.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-search.yaml b/.github/workflows/build-search.yaml index 98f9931..ccf2d78 100644 --- a/.github/workflows/build-search.yaml +++ b/.github/workflows/build-search.yaml @@ -1,4 +1,4 @@ -name: Build Search Indicies +name: build-search-indices on: pull_request: From 90ae581557a6cbdc8b6ce8ad53789ab0631560c4 Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Wed, 10 Dec 2025 09:09:44 -0500 Subject: [PATCH 5/5] Replenish pull step --- .github/workflows/build-search.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-search.yaml b/.github/workflows/build-search.yaml index ccf2d78..505ed30 100644 --- a/.github/workflows/build-search.yaml +++ b/.github/workflows/build-search.yaml @@ -33,6 +33,9 @@ jobs: - name: Restore timestamps uses: chetan/git-restore-mtime-action@v1 + - name: Pull latest changes + run: git pull origin main -X theirs + - name: Setup Node.js uses: actions/setup-node@v4 with: