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
name: Deploy to GitHub Pages | |
on: | |
push: | |
branches: [ main ] # 触发条件:当 main 分支上有推送时 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' # 使用 Node.js 18 版本 | |
cache: 'npm' # 使用 npm 缓存 | |
- name: Install dependencies | |
run: npm ci | |
- name: Build application | |
run: npm run build | |
env: | |
CI: true | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages # 分支名 | |
folder: build # 要部署的文件夹 | |
clean: true # 是否清理旧的文件 |