-
-
Notifications
You must be signed in to change notification settings - Fork 62
39 lines (38 loc) · 1.21 KB
/
update-algolia.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Update the Algolia search index
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
lfs: false
path: website
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: website
- name: Check recent commit
id: checkcommit
working-directory: website
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
run: ALGOLIA_API_KEY=${{ secrets.ALGOLIA_API_KEY }} bundle exec jekyll algolia