Kaynağa Gözat

add search workflow

mitm001 5 yıl önce
ebeveyn
işleme
e2fddc3c21
2 değiştirilmiş dosya ile 63 ekleme ve 0 silme
  1. 46 0
      .github/workflows/algolia-search.yml
  2. 17 0
      production-config.json

+ 46 - 0
.github/workflows/algolia-search.yml

@@ -0,0 +1,46 @@
+# This workflow runs the Algolia scraper for in document searches. It will pull
+#in the pre-built docker image from Algolia and build the search index.
+#
+# The cron schedule syntax determines when to run the scrape.
+# see:
+#   https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule
+#
+# The token set in the secrets tab (configured on the Algolia account)
+# determines what actions can be taken using the scraper with the index.
+# see:
+#   https://www.algolia.com/doc/guides/security/api-keys/#defining-and-securing-access
+#
+# The *-config.json controls how the search works inside the documents themselves.
+# see:
+#   https://docsearch.algolia.com/docs/config-file
+
+name: Algolia Search
+
+on:
+#  schedule:
+#    - cron:  '0 3 * * 0'
+
+  push:
+    branches: [ master ]
+  pull_request:
+
+jobs:
+
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Pull scraper
+      run: docker pull algolia/docsearch-scraper
+
+    - name: Run scraper
+      run: docker run -e "APPLICATION_ID=$APPLICATION_ID" \
+      -e "API_KEY=$API_KEY" \
+      -e "CONFIG=$(cat production-config.json | jq -r tostring)" \
+      algolia/docsearch-scraper
+      env:
+        APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
+        API_KEY: ${{ secrets.API_KEY }}

+ 17 - 0
production-config.json

@@ -0,0 +1,17 @@
+{
+  "index_name": "prod_docs_wiki",
+  "start_urls": ["https://wiki.jmonkeyengine.org/docs/"],
+  "selectors": {
+    "default": {
+      "lvl0": {
+        "global": true,
+        "selector": ".navbar .component"
+      },
+      "lvl1": ".doc > h1.page",
+      "lvl2": ".doc .sect1 > h2:first-child",
+      "lvl3": ".doc .sect2 > h3:first-child",
+      "lvl4": ".doc .sect3 > h4:first-child",
+      "text": ".doc p, .doc dt"
+    }
+  }
+}