-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 修改部署工作流的名称为'Build and Deploy' - 限定工作流仅在push到master分支时触发 - 更新GitHub Actions和部署相关步骤 - 升级`actions/checkout`到v2.3.1 - 使用npm安装pnpm并固定版本为18.14.0 - 修改构建和部署步骤,包括设置环境变量以解决构建时的内存问题 - 使用JamesIves的github-pages-deploy-action进行部署 - 删除了不必要的权限、并发控制和时区设置 此外,还更新了`package.json`文件,添加了deploy脚本和publishConfig,以支持公共npm包的发布。 通过这些更改,提高了部署流程的效率和稳定性,并为将来可能的持续集成/持续部署(CI/CD)流程打下了基础。
- Loading branch information
Null
committed
Jul 28, 2024
1 parent
5cddabc
commit b9372c4
Showing
2 changed files
with
27 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,31 @@ | ||
name: Deploy Pages | ||
|
||
# 触发条件,push到main分支或者pull request到main分支 | ||
name: Build and Deploy | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
# 支持手动在工作流上触发 | ||
workflow_dispatch: | ||
|
||
# 设置时区 | ||
env: | ||
TZ: Asia/Shanghai | ||
|
||
# 权限设置 | ||
permissions: | ||
# 允许读取仓库内容的权限。 | ||
contents: read | ||
# 允许写入 GitHub Pages 的权限。 | ||
pages: write | ||
# 允许写入 id-token 的权限。 | ||
id-token: write | ||
|
||
# 并发控制配置 | ||
concurrency: | ||
group: pages | ||
cancel-in-progress: false | ||
|
||
# 定义执行任务 | ||
branches: | ||
- master | ||
jobs: | ||
# 构建任务 | ||
build: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
# node v20 运行 | ||
strategy: | ||
matrix: | ||
node-version: [18] | ||
|
||
steps: | ||
# 拉取代码 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
# 保留 Git 信息 | ||
fetch-depth: 0 | ||
- name: Checkout ️ | ||
uses: actions/[email protected] | ||
|
||
# 设置使用 Node.js 版本 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
- name: lock npm version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
node-version: 18.14.0 | ||
|
||
# 使用 最新的 PNPM | ||
# 你也可以指定为具体的版本 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
# version: latest | ||
version: 9.2.0 | ||
run_install: false | ||
|
||
# 安装依赖 | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
# 构建项目 | ||
- name: Build blog project | ||
- name: Install and Build | ||
run: | | ||
echo ${{ github.workspace }} | ||
pnpm build | ||
# 资源拷贝 | ||
- name: Build with Jekyll | ||
uses: actions/jekyll-build-pages@v1 | ||
npm i -g pnpm | ||
pnpm run init | ||
pnpm run docs:build | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096 --openssl-legacy-provider' | ||
|
||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
source: ./docs/.vitepress/dist | ||
destination: ./_site | ||
|
||
# 上传 _site 的资源,用于后续部署 | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
|
||
# 部署任务 | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
BRANCH: gh-pages | ||
FOLDER: docs/.vuepress/dist | ||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters