|
9 | 9 | push:
|
10 | 10 | branches:
|
11 | 11 | - next
|
| 12 | + - refactor/deploy |
12 | 13 | workflow_dispatch:
|
13 | 14 |
|
14 | 15 | # 环境变量
|
|
17 | 18 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
18 | 19 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
19 | 20 |
|
| 21 | +# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + pages: write |
| 25 | + id-token: write |
| 26 | + |
20 | 27 | jobs:
|
21 | 28 | # 部署到Github-Pages
|
22 | 29 | deploy-github:
|
23 | 30 | name: 部署到Github-Pages
|
24 |
| - if: github.repository == '142vip/JavaScriptCollection' |
25 | 31 | runs-on: ubuntu-latest
|
| 32 | + environment: |
| 33 | + name: github-pages |
| 34 | + url: ${{ steps.deployment.outputs.page_url }} |
| 35 | + if: github.repository == '142vip/JavaScriptCollection' |
26 | 36 |
|
27 | 37 | steps:
|
28 | 38 | - name: Checkout Code
|
@@ -52,43 +62,19 @@ jobs:
|
52 | 62 | run: |
|
53 | 63 | ./scripts/ci
|
54 | 64 |
|
55 |
| - # 运行构建脚本 |
56 |
| - - name: Build VuePress Site |
57 |
| - run: | |
58 |
| - ./scripts/bundle build_proxy |
59 |
| -
|
60 |
| - # 将README.md同步,利于github pages分支展示 |
61 |
| - - name: Add Readme.md To Dist |
62 |
| - run: | |
63 |
| - cp -f README.md docs/.vuepress/dist |
| 65 | + # 编译 打包成dist |
| 66 | + - name: Build with VitePress |
| 67 | + run: pnpm build:proxy |
64 | 68 |
|
65 |
| - - name: Check GitHub Pages status |
66 |
| - uses: crazy-max/ghaction-github-status@v3 |
| 69 | + - name: Upload artifact |
| 70 | + uses: actions/upload-pages-artifact@v3 |
67 | 71 | with:
|
68 |
| - pages_threshold: major_outage |
| 72 | + path: docs/.vuepress/dist |
69 | 73 |
|
70 |
| - # 获取Git提交信息 |
71 |
| - - name: Get Commit Info |
72 |
| - id: gitInfo |
73 |
| - run: | |
74 |
| - echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
75 |
| - echo "author=$(git log -1 --pretty=%an)" >> $GITHUB_OUTPUT |
76 |
| - echo "email=$(git log -1 --pretty=%ae)" >> $GITHUB_OUTPUT |
77 |
| -
|
78 |
| - # 参考:https://github.com/marketplace/actions/github-pages |
79 |
| - - name: Deploy To GitHub Page |
80 |
| - uses: crazy-max/ghaction-github-pages@v3 |
81 |
| - with: |
82 |
| - target_branch: pages/github |
83 |
| - build_dir: docs/.vuepress/dist |
84 |
| - commit_message: | |
85 |
| - chore(sync): v${{steps.gitInfo.outputs.version}} |
86 |
| -
|
87 |
| - 部署地址: https://142vip.github.io/JavaScriptCollection |
88 |
| - committer: ${{steps.gitInfo.outputs.author}}<${{steps.gitInfo.outputs.email}}> |
89 |
| - author: Mr·Sync |
90 |
| - env: |
91 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + # 部署 |
| 75 | + - name: Deploy to GitHub Pages |
| 76 | + id: deployment |
| 77 | + uses: actions/deploy-pages@v4 |
92 | 78 |
|
93 | 79 | # 部署到vercel平台
|
94 | 80 | # deploy-vercel:
|
@@ -134,13 +120,6 @@ jobs:
|
134 | 120 | # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
135 | 121 | fetch-depth: 0
|
136 | 122 |
|
137 |
| - # ## 打成压缩包 |
138 |
| - - name: Create Zip Package |
139 |
| - run: | |
140 |
| - zip -r JavaScriptCollection.zip . \ |
141 |
| - -x "node_modules/*" \ |
142 |
| - -x "*.git*" |
143 |
| -
|
144 | 123 | # 安装PNPM
|
145 | 124 | - name: PNPM Install
|
146 | 125 | uses: pnpm/action-setup@v4
|
|
0 commit comments