From 90960731752f7b9176c04d80f4baf71932b53b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Wed, 2 Oct 2024 14:51:13 +0200 Subject: [PATCH] Update algolia daily on changes --- .github/workflows/update-algolia.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-algolia.yml b/.github/workflows/update-algolia.yml index b7003972ba..55529a53c6 100644 --- a/.github/workflows/update-algolia.yml +++ b/.github/workflows/update-algolia.yml @@ -2,7 +2,7 @@ name: Update the Algolia search index on: workflow_dispatch: schedule: - - cron: "0 16 * * Sun" + - cron: "0 2 * * *" jobs: build: @@ -18,7 +18,20 @@ jobs: with: bundler-cache: true working-directory: website + - name: Check recent commit + id: checkcommit + run: | + LASTEST_COMMIT=$(git log -1 --format=%ct) + CURRENT_TIME=$(date +%s) + TIME_DIFF=$((CURRENT_TIME - LATEST_COMMIT)) + if [ $TIME_DIFF -gt 86400 ]; then + echo "No commit within 24 hours." + echo "recent_commit=false" >> "$GITHUB_OUTPUT" + else + echo "recent_commit=true" >> "$GITHUB_OUTPUT" + fi - name: Build website and update Algolia index + if: ${{ github.event_name == 'workflow_dispatch' || steps.checkcommit.outputs.recent_commit == 'true' }} working-directory: website env: JEKYLL_ENV: production