-
Notifications
You must be signed in to change notification settings - Fork 8.7k
72 lines (66 loc) · 2.77 KB
/
update-algolia-index.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
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
name: Update Algolia-Search index
# Only trigger, when the build workflow succeeded on branch master
on:
workflow_run:
workflows: ['Build ⚙ and Deploy 🚀']
branches: [master]
types: [completed]
concurrency:
group: algolia-update
cancel-in-progress: true
jobs:
update-algolia-index:
runs-on: ubuntu-latest
steps:
# Try to workaround time gap between newly gh-pages deployment is available (cache cleared?)
- name: Wait for deployment is published
run: |
CNT=1
echo Waiting for deployment ${GITHUB_SHA:0:7} is published
sleep 60
while ! curl -sS https://www.zigbee2mqtt.io/build.txt | grep -qF ${GITHUB_SHA:0:7} ; do
CNT=$((CNT+1))
sleep 1
if [ $CNT -gt 300 ]; then
>&2 echo "build.txt does not match current commit"
>&2 curl -sS https://www.zigbee2mqtt.io/build.txt
exit 1
fi
done
- name: Create algolia scraper config
run: |
cat << EOF > algolia.json
{
"index_name": "zigbee2mqtt.io",
"sitemap_urls": ["https://www.zigbee2mqtt.io/sitemap.xml"],
"stop_urls": [],
"selectors": {
"lvl0": {
"selector": "header .router-link-active",
"global": true,
"default_value": "Miscellaneous"
},
"lvl1": ".content-page h1, .device-page h1",
"lvl2": ".content-page h2, .device-page h1 + table tbody tr:nth-child(3) td:nth-child(2)",
"lvl3": ".content-page h3",
"lvl4": ".content-page h4",
"lvl5": ".content-page h5",
"text": ".content-page p, .content-page li, .content-page code, .content-page td",
"lang": {
"selector": "/html/@lang",
"type": "xpath",
"global": true
}
},
"custom_settings": {
"attributesForFaceting": ["lang"]
}
}
EOF
- run: curl -sSL https://www.zigbee2mqtt.io/build.txt
- name: Update algolia docsearch
uses: psi-4ward/algolia-docsearch-action@master
with:
algolia_application_id: K1BM3QYQ34
algolia_api_key: ${{ secrets.ALGOLIA_INDEX_APIKEY }}
file: 'algolia.json'