-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f63a936
commit 5e64e63
Showing
1 changed file
with
45 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 触发部署的分支 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 检出项目代码 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# 设置 Node.js 版本,并缓存 npm/pnpm 依赖 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' # 指定 Node.js 版本 | ||
cache: 'pnpm' | ||
|
||
# 安装 pnpm | ||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
# 安装依赖 | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
# 构建项目 | ||
- name: Build project | ||
run: pnpm build | ||
|
||
# 部署到 GitHub Pages | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist # 生成静态文件的目录 | ||
|
||
# 清除缓存(可选) | ||
- name: Clean cache | ||
run: pnpm store prune |