1
0

项目:添加修改 GitHub Action

This commit is contained in:
周中平 2022-12-29 11:02:28 +08:00
parent c99bab3f66
commit e51d2e6c69
No known key found for this signature in database
GPG Key ID: B1DF9DD42D8E00DC
4 changed files with 85 additions and 2 deletions

24
.github/workflows/algolia.yml vendored Normal file
View File

@ -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

View File

@ -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

51
.github/workflows/docsearch.json vendored Normal file
View File

@ -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
}

View File

@ -43,6 +43,14 @@ Main 主分支
└─ phone 移动分支
```
## CI&CD
- build.ymlmain 分支自动构建静态网站,并部署至 html 分支。
- algolia.yml每周三凌晨 0200 自动爬取并推送至 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 贡献,并提供指导纠错。 👊