-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (30 loc) · 944 Bytes
/
deploy.yml
File metadata and controls
36 lines (30 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Deploy Frontend
on:
push:
branches:
- main # 触发部署的分支,通常是 main 或 master
jobs:
deploy:
runs-on: ubuntu-latest # 使用最新的 Ubuntu 环境
steps:
# 检出代码
- name: Checkout code
uses: actions/checkout@v4
# 设置 Node.js 环境
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22" # 使用 Node.js 22.x
- name: Enable Corepack
run: corepack enable
# 安装依赖并构建前端
- name: Install dependencies and build frontend
run: |
yarn install
yarn build
# 同步构建的文件到服务器
- name: Deploy with rsync
run: |
rsync -avz --delete ./frontend/dist/ rsyncuser@your-server:/var/www/html/frontend/
env:
RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }} # 可选:如果使用密码验证