|
1 | | -name: site sync |
| 1 | +name: Deploy Site |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [main] |
| 5 | + branches: |
| 6 | + - v4-next |
6 | 7 | paths: |
7 | 8 | - .github/workflows/site.yml |
8 | 9 | - site/** |
9 | 10 | - CHANGELOG.md |
10 | | - # repository_dispatch: |
11 | | - # types: [update-hooks-docs] |
| 11 | + # Review gh actions docs if you want to further define triggers, paths, etc |
| 12 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on |
12 | 13 |
|
13 | 14 | jobs: |
14 | 15 | build: |
15 | | - |
16 | | - runs-on: ubuntu-latest |
17 | | - |
| 16 | + name: Build Docusaurus |
18 | 17 | strategy: |
19 | 18 | matrix: |
20 | 19 | node-version: [20.x] |
| 20 | + os: [ubuntu-latest] |
| 21 | + runs-on: ${{ matrix.os }} |
21 | 22 |
|
22 | 23 | steps: |
23 | 24 | - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Install pnpm |
| 29 | + uses: pnpm/action-setup@v4 |
| 30 | + with: |
| 31 | + version: 9 |
| 32 | + run_install: false |
| 33 | + |
24 | 34 | - name: Use Node.js ${{ matrix.node-version }} |
25 | 35 | uses: actions/setup-node@v4 |
26 | 36 | with: |
27 | 37 | node-version: ${{ matrix.node-version }} |
28 | | - - name: action-zip |
29 | | - uses: montudor/action-zip@v1.0.0 |
| 38 | + cache: 'pnpm' |
30 | 39 |
|
31 | | - # 安装根目录依赖 |
32 | 40 | - name: Install root dependencies |
33 | | - run: npm install |
| 41 | + run: pnpm install |
34 | 42 |
|
35 | | - # 构建根目录项目 |
36 | 43 | - name: Build root project |
37 | | - run: npm run build --if-present |
| 44 | + run: pnpm run build --if-present |
| 45 | + |
| 46 | + # site 目录使用 npm,需要单独配置 npm 缓存 |
| 47 | + - uses: actions/setup-node@v4 |
| 48 | + with: |
| 49 | + node-version: ${{ matrix.node-version }} |
| 50 | + cache: 'npm' |
| 51 | + cache-dependency-path: site/package-lock.json |
38 | 52 |
|
39 | 53 | # 安装和构建 site 目录 |
40 | 54 | - name: Install and build site |
|
43 | 57 | npm install |
44 | 58 | npm run build |
45 | 59 |
|
46 | | - # 打包文档 |
| 60 | + # 打包文档,部署到阿里云 OSS |
47 | 61 | - name: Zip output |
48 | 62 | working-directory: site |
49 | 63 | run: zip -r build/document_archive.zip docs i18n blog versioned_docs versioned_sidebars |
|
56 | 70 | # use your own endpoint |
57 | 71 | endpoint: oss-cn-hongkong.aliyuncs.com |
58 | 72 | folder: site/build |
| 73 | + |
| 74 | + # 部署到 GitHub Pages |
| 75 | + - name: Upload Build Artifact |
| 76 | + uses: actions/upload-pages-artifact@v3 |
| 77 | + with: |
| 78 | + path: site/build |
| 79 | + |
| 80 | + deploy: |
| 81 | + name: Deploy to GitHub Pages |
| 82 | + needs: build |
| 83 | + |
| 84 | + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment |
| 85 | + permissions: |
| 86 | + pages: write # to deploy to Pages |
| 87 | + id-token: write # to verify the deployment originates from an appropriate source |
| 88 | + |
| 89 | + # Deploy to the github-pages environment |
| 90 | + environment: |
| 91 | + name: github-pages |
| 92 | + url: ${{ steps.deployment.outputs.page_url }} |
| 93 | + |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - name: Deploy to GitHub Pages |
| 97 | + id: deployment |
| 98 | + uses: actions/deploy-pages@v4 |
0 commit comments