Skip to content

Commit 8329a4c

Browse files
Merge pull request #318 from Websoft9/feat/docs-cicd-bmad-standardization
feat: docs/cicd/bmad standardization
2 parents 1bbe3be + a856181 commit 8329a4c

15 files changed

Lines changed: 712 additions & 142 deletions

File tree

.github/workflows/app_from_contentful.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 从 Contentful CMS 自动生成 App 应用的元数据文档(_include/)和 App 文档骨架。
2+
# 触发方式:管理员手动触发(workflow_dispatch),需要仓库 Write 权限 + CONTENTFUL_ACCESS_TOKEN。
3+
# 注意:该 workflow 生成的 _include/ 文件不应手工修改,属于自动管理内容。
4+
15
name: Generate Apps header and appdocs files
26

37
on:
@@ -8,14 +12,15 @@ jobs:
812
runs-on: ubuntu-latest
913

1014
steps:
11-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1216
with:
1317
fetch-depth: 0
1418

1519
- name: Set up Python
16-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5
1721
with:
1822
python-version: '3.x'
23+
cache: 'pip'
1924

2025
- name: Install dependencies
2126
run: |
@@ -26,9 +31,9 @@ jobs:
2631
env:
2732
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_GRAPHQLTOKEN }}
2833
run: |
29-
python builds/gen_md_from_contenful.py template/meta/zh_head.jinja2 versioned_docs/version-2.0/apps/_include --override
30-
python builds/gen_md_from_contenful.py template/meta/en_head.jinja2 i18n/en/docusaurus-plugin-content-docs/version-2.0/apps/_include --override
31-
python builds/gen_md_from_contenful.py template/meta/zh_app.jinja2 versioned_docs/version-2.0/apps --ignore-list template/meta/skip_file.json
34+
python builds/gen_md_from_contenful.py template/meta/zh_head.jinja2 versioned_docs/version-2.0/apps/_include
35+
python builds/gen_md_from_contenful.py template/meta/en_head.jinja2 i18n/en/docusaurus-plugin-content-docs/version-2.0/apps/_include
36+
python builds/gen_md_from_contenful.py template/meta/zh_app.jinja2 versioned_docs/version-2.0/apps --ignore-list template/meta/skip_file.json
3237
python builds/gen_md_from_contenful.py template/meta/en_app.jinja2 i18n/en/docusaurus-plugin-content-docs/version-2.0/apps --ignore-list template/meta/skip_file.json
3338
3439
- name: Commit and push changes

.github/workflows/build_doc.yml

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
# This workflow is triggered on pushes and pull requests to any branch.
2-
# The job name includes the branch name dynamically.
1+
# 文档构建与部署工作流
2+
# - dev 分支:只构建,不部署(用于验证 PR 不破坏构建)
3+
# - main 分支:构建 + 部署到 Cloudflare Pages(生产环境)
34

45
name: Docs Build and Upload to Cloudflare
56

6-
on:
7+
on:
78
workflow_dispatch:
89
push:
910
branches:
1011
- dev
1112
- main
12-
paths:
13+
paths:
14+
- 'docs/**'
15+
- 'versioned_docs/**'
16+
- 'i18n/**'
17+
- 'src/**'
18+
- 'static/**'
19+
- '**.js'
20+
- '.github/workflows/**'
21+
- '!docs/_list'
22+
pull_request:
23+
branches:
24+
- dev
25+
paths:
1326
- 'docs/**'
1427
- 'versioned_docs/**'
1528
- 'i18n/**'
@@ -18,57 +31,65 @@ on:
1831
- '**.js'
1932
- '!docs/_list'
2033

34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.ref }}
36+
cancel-in-progress: true
37+
2138
jobs:
2239
build:
2340
name: Build on branch ${{ github.ref_name }}
2441
runs-on: ubuntu-latest
25-
#if: false # stop steps
2642
steps:
27-
- uses: actions/checkout@master
43+
- uses: actions/checkout@v4
44+
2845
- uses: actions/setup-node@v4
2946
with:
30-
node-version: 20
47+
node-version: 20
48+
49+
- name: Cache yarn dependencies
50+
uses: actions/cache@v4
51+
with:
52+
path: node_modules
53+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
54+
restore-keys: |
55+
${{ runner.os }}-yarn-
56+
3157
- name: Docusaurus build
3258
run: |
3359
yarn install
3460
yarn run build
3561
env:
3662
CI: true
37-
38-
- name: Debug
39-
run: ls
4063

4164
- name: Create apidocs directory and add files
65+
continue-on-error: true
4266
run: |
4367
mkdir -p build/apidocs
4468
cd build/apidocs
4569
wget -O redoc.standalone.js https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
4670
wget -O README.md https://websoft9.github.io/websoft9/apphub/apidocs/README.md
4771
wget -O index.html https://websoft9.github.io/websoft9/apphub/apidocs/index.html
4872
docker run -d --name apphub -p 8080:8080 websoft9dev/apphub:latest
49-
sleep 5
50-
max_attempts=10
51-
url="http://localhost:8080/openapi.json"
52-
for attempt in $(seq 1 $max_attempts); do
53-
echo "Attempt #$attempt to download $url..."
54-
if wget -O openapi.json "$url"; then
55-
echo "Successfully downloaded $url"
56-
break
57-
else
58-
echo "Failed to download $url. Waiting for 5 seconds before retry..."
59-
sleep 5
60-
fi
61-
done
73+
sleep 5
74+
max_attempts=10
75+
url="http://localhost:8080/openapi.json"
76+
for attempt in $(seq 1 $max_attempts); do
77+
echo "Attempt #$attempt to download $url..."
78+
if wget -O openapi.json "$url"; then
79+
echo "Successfully downloaded $url"
80+
break
81+
else
82+
echo "Failed to download $url. Waiting for 5 seconds before retry..."
83+
sleep 5
84+
fi
85+
done
6286
6387
- name: Publish to Cloudflare Pages
88+
if: github.ref == 'refs/heads/main'
6489
uses: cloudflare/pages-action@v1
6590
with:
6691
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6792
accountId: eb79f13320db531d8cf1f3720966b695
6893
projectName: doc-websoft9-com
6994
directory: build
70-
# Optional: Enable this if you want to have GitHub Deployments triggered
7195
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
72-
# Optional: Switch what branch you are publishing to.
73-
# By default this will be the branch which triggered this workflow
74-
# branch: dev

.github/workflows/check.yml

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1-
# ProxyCheck: Read dockerhub proxy URL from docs/reference/_include/dockerhub-proxy.md and test the network speed
2-
# Spellcheck
1+
# 文档质量检查工作流
2+
# - push 到 dev 分支时触发
3+
# - 向 dev 分支提 PR 时触发(作为合并前的强制质量门)
4+
# 功能:使用 lychee 检查文档中的 broken links,结果输出为 artifact
35

46
name: Check Action
57

6-
on:
8+
on:
79
workflow_dispatch:
810
push:
911
branches:
1012
- dev
11-
13+
pull_request:
14+
branches:
15+
- dev
16+
1217
jobs:
18+
broken-links:
19+
name: Broken Links Check
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Check broken links
25+
uses: lycheeverse/lychee-action@v2
26+
with:
27+
args: >-
28+
--verbose
29+
--no-progress
30+
--exclude-path node_modules
31+
--exclude-path build
32+
versioned_docs/
33+
i18n/
34+
fail: false
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1337

14-
# Spellcheck:
15-
# name: Spellcheck
16-
# runs-on: ubuntu-latest
17-
# steps:
18-
# - uses: actions/checkout@v3
19-
# - uses: rojopolis/spellcheck-github-actions@0.41.0
20-
# name: Spellcheck
21-
# with:
22-
# source_files: i18n/en/docusaurus-plugin-content-docs/current/**/*.md
23-
# task_name: Markdown
24-
# output_file: spellcheck-output.txt
38+
- name: Upload lychee results
39+
uses: actions/upload-artifact@v4
40+
if: always()
41+
with:
42+
name: lychee-report
43+
path: lychee/out.md
44+
retention-days: 7
2545

26-
# - uses: actions/upload-artifact@v3
27-
# if: '!cancelled()' # Do not upload artifact if job was cancelled
28-
# with:
29-
# name: Spellcheck Output
30-
# path: spellcheck-output.txt

.github/workflows/json2md.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1+
# 从制品文件生成 App 应用目录列表 Markdown。
2+
# 触发方式:手动触发 或 repository_dispatch(事件名: applist_dev_event)。
3+
# repository_dispatch 由 Websoft9 主仓库 release 时自动触发。
4+
15
name: Generate Apps list for docs
26

37
on:
48
workflow_dispatch:
59
repository_dispatch:
610
types: [applist_dev_event]
7-
11+
812
jobs:
913
build:
1014
runs-on: ubuntu-latest
1115

1216
steps:
13-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1418

1519
- name: Setup Python
16-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5
1721
with:
1822
python-version: "3.x"
23+
cache: 'pip'
1924

2025
- name: Install unzip utility
2126
run: sudo apt-get install unzip
2227

2328
- name: Download and unzip JSON files
2429
run: |
25-
curl -L -o media-latest.zip https://artifact.websoft9.com/release/websoft9/plugin/media/media-latest.zip
30+
curl -L --retry 3 --retry-delay 5 --retry-connrefused --fail \
31+
-o media-latest.zip https://artifact.websoft9.com/release/websoft9/plugin/media/media-latest.zip
2632
unzip media-latest.zip "media/json/product_zh.json" "media/json/product_en.json" "media/json/catalog_zh.json" "media/json/catalog_en.json" -d ./extracted
2733
2834
- name: Generate Markdown for app catalog README.mdx(zh)
@@ -53,3 +59,4 @@ jobs:
5359
uses: stefanzweifel/git-auto-commit-action@v4
5460
with:
5561
commit_message: Update Product Catalog Markdown
62+

.github/workflows/update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout
11-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1212

1313
- name: Install dependencies
1414
run: |

.lycheeignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# lychee broken-links 检查排除规则
2+
# 以下 pattern 匹配的链接将不被检查
3+
4+
# 本地开发地址
5+
localhost
6+
127.0.0.1
7+
8+
# CDN 图片域名(外网请求不稳定,大量图片链接)
9+
libs.websoft9.com
10+
11+
# Algolia 搜索相关(动态 URL 中出现的 appId 和 indexName)
12+
NA4GDUSQ4H
13+
support-websoft9
14+
15+
# 内部支持站点
16+
support.websoft9.com
17+
18+
# 文档模板占位链接
19+
example.com

CHANGELOG.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1-
# 开发日志
1+
# Changelog
2+
3+
本文件记录本项目的所有重要变更,遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/) 规范。
4+
5+
版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)
6+
7+
---
8+
9+
## [Unreleased]
10+
11+
### Added
12+
13+
- 新增 `CONTRIBUTING.md` 贡献指南(由 `developer.md` 重命名并全面重写),包含分支策略、PR 规范、i18n 说明、文档原则和常见问题
14+
- 新增 `DEVELOPMENT.md` 开发手册,包含环境配置、本地开发命令、模板系统说明、CI/CD 工作流说明、BMAD Quick Flow 使用指南和 App 文档创建标准流程
15+
- 新增 `template/docs/zh/app.md` Quick Flow 专用 App 文档 Prompt 模板
16+
- 新增 `.lycheeignore` broken-links 检查排除规则文件
17+
18+
### Changed
19+
20+
- `README.md` 全面重写:新增 CI badge、Tech Stack badge、快速开始、项目结构和文档链接
21+
- `docs/readme.md` 更新为 next 版本说明
22+
- `build_doc.yml`:升级 `checkout@master``@v4`,新增 yarn cache、concurrency 控制,删除调试步骤,修复 Docker 缩进,区分 dev/main 分支部署行为,apidocs 步骤设为 `continue-on-error: true`,新增 `pull_request` 触发(PR 构建质量门)
23+
- `check.yml`:全量重写,恢复 broken-links 检查(`lychee-action@v2`),新增 PR 触发
24+
- `app_from_contentful.yml`:升级 `checkout@v2``@v4``setup-python@v2``@v5`,新增 pip cache,移除 `--override` 参数
25+
- `json2md.yml`:升级 `checkout@v2``@v4``setup-python@v2``@v5`,新增 pip cache,curl 新增重试参数
26+
- `update.yml`:升级 `checkout@v2``@v4`
27+
28+
### Removed
29+
30+
- 删除 `Notes.md`(内容已迁移至 `CONTRIBUTING.md`
31+
- 删除 `add_apps.md`(纯占位文件)
32+
33+
---
34+
35+
<!-- 版本链接占位 -->
36+
[Unreleased]: https://github.com/Websoft9/doc.websoft9.com/compare/HEAD...HEAD
237

0 commit comments

Comments
 (0)