Skip to content

Feat/docs cicd bmad standardization #3

Feat/docs cicd bmad standardization

Feat/docs cicd bmad standardization #3

Workflow file for this run

# CI 主工作流
# - check job:lychee 外链检查(仅 dev push / PR,main 跳过)
# - build job:Docusaurus 构建,依赖 check 通过;main 分支额外部署到 Cloudflare Pages
name: CI
on:
workflow_dispatch:
push:
branches:
- dev
- main
paths:
- 'docs/**'
- 'versioned_docs/**'
- 'i18n/**'
- 'src/**'
- 'static/**'
- '**.js'
- '.github/workflows/**'
- '!docs/_list'
pull_request:
branches:
- dev
paths:
- 'docs/**'
- 'versioned_docs/**'
- 'i18n/**'
- 'src/**'
- 'static/**'
- '**.js'
- '.github/workflows/**'
- '!docs/_list'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Broken Links Check
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Check broken links
uses: lycheeverse/lychee-action@v2
with:
args: >-
--verbose
--no-progress
--exclude-path node_modules
--exclude-path build
versioned_docs/
i18n/
fail: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload lychee results
uses: actions/upload-artifact@v4
if: failure()
with:
name: lychee-report
path: lychee/out.md
retention-days: 7
build:
name: Build on branch ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: check
if: always() && (needs.check.result == 'success' || needs.check.result == 'skipped')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Docusaurus build
run: |
yarn install
yarn run build
env:
CI: true
- name: Create apidocs directory and add files
continue-on-error: true
run: |
mkdir -p build/apidocs
cd build/apidocs
wget -O redoc.standalone.js https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
wget -O README.md https://websoft9.github.io/websoft9/apphub/apidocs/README.md
wget -O index.html https://websoft9.github.io/websoft9/apphub/apidocs/index.html
docker run -d --name apphub -p 8080:8080 websoft9dev/apphub:latest
sleep 5
max_attempts=10
url="http://localhost:8080/openapi.json"
for attempt in $(seq 1 $max_attempts); do
echo "Attempt #$attempt to download $url..."
if wget -O openapi.json "$url"; then
echo "Successfully downloaded $url"
break
else
echo "Failed to download $url. Waiting for 5 seconds before retry..."
sleep 5
fi
done
- name: Publish to Cloudflare Pages
if: github.ref == 'refs/heads/main'
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: eb79f13320db531d8cf1f3720966b695
projectName: doc-websoft9-com
directory: build
gitHubToken: ${{ secrets.GITHUB_TOKEN }}