diff --git a/.github/workflows/algolia.yml b/.github/workflows/algolia.yml new file mode 100644 index 00000000..4f5bd285 --- /dev/null +++ b/.github/workflows/algolia.yml @@ -0,0 +1,24 @@ +name: Algolia Push Data +on: + schedule: + - cron: '0 2 * * 3' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run Crawler + env: + ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }} + ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} + run: | + sudo apt-get update && + sudo apt-get install -y jq && + docker run -t\ + -e APPLICATION_ID=$ALGOLIA_APP_ID \ + -e API_KEY=$ALGOLIA_ADMIN_API_KEY \ + -e "CONFIG=$(cat .github/workflows/docsearch.json | jq -r tostring)" \ + algolia/docsearch-scraper \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78579c23..caaf8968 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: build +name: Build HTML on: push: branches: @@ -15,7 +15,7 @@ jobs: with: node-version: 18 - - name: Build + - name: Build HTML run: | npm install npm run build diff --git a/.github/workflows/docsearch.json b/.github/workflows/docsearch.json new file mode 100644 index 00000000..eb612b6d --- /dev/null +++ b/.github/workflows/docsearch.json @@ -0,0 +1,51 @@ +{ + "index_name": "wiki", + "start_urls": [ + "https://wiki.7wate.com/" + ], + "sitemap_urls": [ + "https://wiki.7wate.com/sitemap.xml" + ], + "stop_urls": [ + "/search", + "/v3me", + "/playground", + "/inspector" + ], + "sitemap_alternate_links": true, + "selectors": { + "lvl0": { + "selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]", + "type": "xpath", + "global": true, + "default_value": "Documentation" + }, + "lvl1": "header h1", + "lvl2": "article h2", + "lvl3": "article h3", + "lvl4": "article h4", + "lvl5": "article h5, article td:first-child", + "lvl6": "article h6", + "text": "article p, article li, article td:last-child" + }, + "strip_chars": " .,;:#", + "custom_settings": { + "separatorsToIndex": "_", + "attributesForFaceting": [ + "language", + "version", + "type", + "docusaurus_tag" + ], + "attributesToRetrieve": [ + "hierarchy", + "content", + "anchor", + "url", + "url_without_anchor", + "type" + ] + }, + "js_render": true, + "nb_hits": 856 + } \ No newline at end of file diff --git a/README.md b/README.md index b8e050d8..7c6da464 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,14 @@ Main 主分支 └─ phone 移动分支 ``` +## CI&CD + + - build.yml:main 分支自动构建静态网站,并部署至 html 分支。 + - algolia.yml:每周三凌晨 02:00 自动爬取并推送至 Algolia。 + 1. 设置 `ALGOLIA_ADMIN_API_KEY`、`ALGOLIA_APP_ID` 仓库环境密钥,密钥获取具体步骤请阅读 [使用 Docusaurus 搭建优秀个人wiki](https://blog.7wate.com/?p=75)。 + 2. 修改 `.github\workflows\docsearch.json` 目录下 `start_urls` 和 `sitemap_urls` 键值为对应网站。 + + ## 贡献 欢迎各位 Fork 贡献,并提供指导纠错。 👊