MCDReforged / MCDReforged

A rewritten version of MCDaemon, a python tool to control your Minecraft server
https://mcdreforged.com
GNU Lesser General Public License v3.0
865 stars 78 forks source link

[doc] Run Algolia Crawler only on doc update #282

Open alex3236 opened 6 months ago

alex3236 commented 6 months ago

Currently, the Algolia index runs every 2 days at 17:00. This results in a lot of unnecessary reindexing, and users may be redirected to an invalid link when searching.

So we can reindex Algolia only when the document is updated and deployed on ReadTheDocs.

ReadTheDocs deployment does not seem to be a github deployment or workflow, so I can't give the example to run after deployment.

(ReadTheDocs runs on every commit? if so, maybe add a condition, run reindex only on changes in /docs.)

Github workflow example:

jobs:
    algolia_index:
      runs-on: ubuntu-latest
      steps:
        - name: Checkout
          uses: actions/checkout@v3
          with:
            fetch-depth: 1

        - name: Reindex Algolia Crawler
          # https://www.algolia.com/doc/rest-api/crawler/#reindex-with-a-crawler
          run: |
            curl -H "Content-Type: application/json" -X POST --user ${{ secrets.ALGOLIA_USER_ID }}:${{ secrets.ALGOLIA_CRAWLER_API_KEY }} "https://crawler.algolia.com/api/1/crawlers/${{ secrets.ALGOLIA_CRAWLER_ID }}/reindex"

Where USER_ID and API_KEY can be found in User Settings CRAWLER_ID can be found in Crawlers -> Crawler -> Settings.

When these are done, simply delete the schedule pattern in Crawler Editor, as it's default to never.

alex3236 commented 6 months ago

I think this is a low priority thing though