diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index bab0fbdc26..ebccdb18e3 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -153,6 +153,42 @@ When the crawl is complete, MeiliSearch stores the crawled document in the speci > See +### Using Github Action for Automatic Scraping + +In the Github repository, go to `Settings` -> `Secrets and variables` -> `Actions` -> `New repository secret` to set `MEILISEARCH_API_KEY` and `MEILISEARCH_HOST_URL`. And name your scraper configuration file `meilisearch-scraper.json` and place it in the root directory of your project. + +```yml +name: Deploy and Scrape + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + # .... + scrapy: + needs: deploy + runs-on: ubuntu-latest + name: scrape and push content on Meilisearch instance + steps: + - uses: actions/checkout@v4 + - name: Run scraper + env: + HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }} + API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} + CONFIG_FILE_PATH: ${{ github.workspace }}/meilisearch-scraper.json + run: | + docker run -t --rm \ + -e MEILISEARCH_HOST_URL=$HOST_URL \ + -e MEILISEARCH_API_KEY=$API_KEY \ + -v $CONFIG_FILE_PATH:/docs-scraper/config.json \ + getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json +``` + ## Get search index and api key To create an access key that only allows search operations, use the following request. The `indexes` array specifies which indexes this key can access, and `expiresAt` sets the key's expiration date. diff --git a/docs/zh/plugins/search/meilisearch.md b/docs/zh/plugins/search/meilisearch.md index 511d54fae8..9b0af2f76a 100644 --- a/docs/zh/plugins/search/meilisearch.md +++ b/docs/zh/plugins/search/meilisearch.md @@ -153,6 +153,42 @@ docker run -t --rm \ > 参考 +### 使用 Github Action 自动抓取 + +在 Github 仓库的`Settings` -> `Secrets and variables` -> `Actions` -> `New repository secret`设置`MEILISEARCH_API_KEY`和`MEILISEARCH_HOST_URL`,并将你的爬虫配置文件命名为 `melisearch_scraper.json` 放到项目根目录下。 + +```yml +name: Deploy and Scrape + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + # .... + scrapy: + needs: deploy + runs-on: ubuntu-latest + name: scrape and push content on Meilisearch instance + steps: + - uses: actions/checkout@v4 + - name: Run scraper + env: + HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }} + API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} + CONFIG_FILE_PATH: ${{ github.workspace }}/meilisearch-scraper.json + run: | + docker run -t --rm \ + -e MEILISEARCH_HOST_URL=$HOST_URL \ + -e MEILISEARCH_API_KEY=$API_KEY \ + -v $CONFIG_FILE_PATH:/docs-scraper/config.json \ + getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json +``` + ## 获取搜索索引和 API 密钥 要创建只允许搜索操作的访问密钥,请使用以下请求。`indexes` 数组指定该密钥可以访问哪些索引,`expiresAt` 设置密钥的过期时间。