@@ -15,53 +15,6 @@ concurrency:
1515 cancel-in-progress : false
1616
1717jobs :
18- # 构建文档 - 使用现有 docker-compose.yml
19- build-docs :
20- runs-on : ubuntu-latest
21- steps :
22- - name : Checkout
23- uses : actions/checkout@v4
24- with :
25- fetch-depth : 0
26-
27- - name : Build documentation using docker-compose
28- run : |
29- # 检查并使用合适的 docker compose 命令
30- if command -v docker-compose &> /dev/null; then
31- DOCKER_COMPOSE="docker-compose"
32- else
33- DOCKER_COMPOSE="docker compose"
34- fi
35-
36- # 使用现有的 docker-compose.yml 构建 mockm-dev 服务
37- $DOCKER_COMPOSE build mockm-dev
38-
39- # 运行文档构建命令
40- $DOCKER_COMPOSE run --rm mockm-dev \
41- sh -c "git config --global --add safe.directory /workspace && cd doc && rm -rf .vuepress/dist && GITHUB_ACTIONS=true pnpm run build"
42-
43- - name : Copy test resources
44- run : |
45- mkdir -p doc/.vuepress/dist/case
46- cp -r test/res/* doc/.vuepress/dist/case/ || true
47-
48- - name : Upload Pages artifact
49- uses : actions/upload-pages-artifact@v3
50- with :
51- path : doc/.vuepress/dist
52-
53- # 部署到 GitHub Pages
54- deploy-pages :
55- environment :
56- name : github-pages
57- url : ${{ steps.deployment.outputs.page_url }}
58- runs-on : ubuntu-latest
59- needs : build-docs
60- steps :
61- - name : Deploy to GitHub Pages
62- id : deployment
63- uses : actions/deploy-pages@v4
64-
6518 # 构建和发布包 - 使用现有 docker-compose.yml
6619 build-and-release :
6720 runs-on : ubuntu-latest
8740 $DOCKER_COMPOSE run --rm mockm-client \
8841 sh -c "cd client && yarn build"
8942
90- # 构建服务端包
43+ # 运行测试并生成报告
9144 $DOCKER_COMPOSE run --rm mockm-dev \
92- sh -c "git config --global --add safe.directory /workspace && cd release && pnpm run build"
45+ sh -c "npm run test:dev"
46+
47+ # 构建生产内容:包、文档、复制测试报告
48+ $DOCKER_COMPOSE run --rm \
49+ -e GITHUB_ACTIONS=true \
50+ mockm-dev \
51+ sh -c "git config --global --add safe.directory /workspace && npm run build:serve"
9352
9453 - name : Get package info
9554 run : |
9857 echo "PACKAGE_NAME=mockm" >> $GITHUB_ENV
9958
10059 - name : Create Release
101- uses : softprops/action-gh -release@v1
60+ uses : mini-bomba/create-github -release@v1.2.0
10261 with :
103- tag_name : v${{ env.VERSION }}
62+ token : ${{ secrets.GITHUB_TOKEN }}
63+ tag : v${{ env.VERSION }}
10464 name : Release v${{ env.VERSION }}
10565 body : |
10666 ## Changes in v${{ env.VERSION }}
@@ -115,12 +75,11 @@ jobs:
11575
11676 ### Download
11777 - [mockm-${{ env.VERSION }}.tgz](https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/mockm-${{ env.VERSION }}.tgz)
118- draft : false
11978 prerelease : false
79+ draft : false
12080 files : |
12181 dist/*.tgz
122- env :
123- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82+ clear_attachments : true
12483
12584 - name : Cleanup Docker resources
12685 if : always()
@@ -134,3 +93,20 @@ jobs:
13493
13594 $DOCKER_COMPOSE down --volumes --remove-orphans || true
13695 docker system prune -f || true
96+
97+ - name : Upload Pages artifact
98+ uses : actions/upload-pages-artifact@v3
99+ with :
100+ path : doc/.vuepress/dist
101+
102+ # 部署到 GitHub Pages
103+ deploy-pages :
104+ environment :
105+ name : github-pages
106+ url : ${{ steps.deployment.outputs.page_url }}
107+ runs-on : ubuntu-latest
108+ needs : build-and-release
109+ steps :
110+ - name : Deploy to GitHub Pages
111+ id : deployment
112+ uses : actions/deploy-pages@v4
0 commit comments