From e51d2e6c6989ff197a7c86ec442a4b846f06f6bf Mon Sep 17 00:00:00 2001 From: 7Wate Date: Thu, 29 Dec 2022 11:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20GitHub=20Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/algolia.yml | 24 +++++++++++++++ .github/workflows/build.yml | 4 +-- .github/workflows/docsearch.json | 51 ++++++++++++++++++++++++++++++++ README.md | 8 +++++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/algolia.yml create mode 100644 .github/workflows/docsearch.json 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 贡献,并提供指导纠错。 👊