-
Notifications
You must be signed in to change notification settings - Fork 1.3k
96 lines (83 loc) · 3.58 KB
/
Copy pathmeilisearch-scraper.yml
File metadata and controls
96 lines (83 loc) · 3.58 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Meilisearch Documentation Scraper
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
jobs:
scrape-docs:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Wait for deployment (if push event)
if: github.event_name == 'push'
run: sleep 60
- name: Validate JSON config
run: |
echo "Validating JSON configuration..."
python3 -c "import json; json.load(open('.github/workflows/meilisearch-scraper-config.json'))"
echo "JSON is valid!"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install scraper helper deps
working-directory: docusaurus
run: yarn install --frozen-lockfile
# Back up the current index (settings + all documents) BEFORE the scrape
# replaces it, so a bad scrape can be rolled back. Saved as a downloadable
# GitHub artifact (retained 30 days).
- name: Back up index before scrape
working-directory: docusaurus
env:
MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST_URL }}
MEILISEARCH_MASTER_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }}
MEILISEARCH_BACKUP_DIR: ${{ github.workspace }}/meilisearch-backups
run: node scripts/meilisearch/backup-index.js
- name: Upload index backup artifact
uses: actions/upload-artifact@v4
with:
name: meilisearch-backup-${{ github.run_id }}
path: meilisearch-backups/
retention-days: 30
if-no-files-found: warn
- name: Run Meilisearch Scraper
env:
MEILISEARCH_HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }}
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }}
run: |
docker run \
-e MEILISEARCH_HOST_URL="$MEILISEARCH_HOST_URL" \
-e MEILISEARCH_API_KEY="$MEILISEARCH_API_KEY" \
-v ${{ github.workspace }}/.github/workflows:/config \
getmeili/docs-scraper:v0.12.8 \
pipenv run ./docs_scraper /config/meilisearch-scraper-config.json
# The scrape rewrites the index and its ranking rules from the scraper
# config, which has no category_order. Re-apply the category ordering so
# results stay grouped by section (otherwise this is silently lost on
# every run). Reads docusaurus/scripts/meilisearch/category-order-config.json.
- name: Apply category ordering
working-directory: docusaurus
env:
MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST_URL }}
MEILISEARCH_MASTER_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }}
run: node scripts/meilisearch/add-category-order.js
- name: Test search index
env:
MEILISEARCH_HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }}
MEILISEARCH_SEARCH_KEY: ${{ secrets.MEILISEARCH_SEARCH_KEY }}
run: |
echo "Testing search functionality..."
curl -s "$MEILISEARCH_HOST_URL/indexes/strapi-docs/search" \
-H "Authorization: Bearer $MEILISEARCH_SEARCH_KEY" \
-H 'Content-Type: application/json' \
--data '{"q":"strapi","limit":5}' | \
python3 -m json.tool
echo "Checking index stats..."
curl -s "$MEILISEARCH_HOST_URL/indexes/strapi-docs/stats" \
-H "Authorization: Bearer $MEILISEARCH_SEARCH_KEY" | \
python3 -m json.tool