chore: deploy 触发分支改 master,竞品调研/原型/色板/i18n/分享组件/文档等成果入库

This commit is contained in:
Sisyphus committed 2026-08-14 09:58:52 +08:00
1 parent 5a97e6124e
commit 40e2342a02
75 files changed
+6848 -540

No files matched your search

+25 -8
View File
@@ -1,6 +1,6 @@
# =============================================================================
# PERLER LAB — GitHub Actions CI/CD 流水线
# 触发条件:推送到 main 分支 或 手动触发
# 触发条件:推送到 master 分支 或 手动触发
# 流程:
# 1. test — 安装依赖 + 运行测试(前后端并行)
# 2. build — 构建 Docker 镜像(验证 Dockerfile 正确)
@@ -10,9 +10,15 @@ name: Deploy
on:
push:
branches: [main]
branches: [master]
workflow_dispatch:
concurrency:
# 同一分支同一工作流的运行串行执行,防止并行部署到生产服务器
# cancel-in-progress: false —— 排队等待而非取消,避免中断进行中的部署
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
# 镜像标签——使用 commit SHA 保证唯一性,部署时通过 docker compose up -d --build 重建
# 若需推送镜像到 registry,在此取消注释并配置后续步骤
@@ -23,12 +29,13 @@ jobs:
# ── 测试 ──
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
project:
- name: perler-lab
# perler-lab 无 package-lock.json,使用 npm install
install-cmd: npm install
# perler-lab 有 package-lock.json,使用 npm ci 保证可复现
install-cmd: npm ci
- name: perler-lab-server
# perler-lab-server 有 package-lock.json,使用 npm ci 保证可复现
install-cmd: npm ci
@@ -46,16 +53,22 @@ jobs:
run: |
${{ matrix.project.install-cmd }} --no-audit --no-fund
npm test
# 额外:前端执行类型检查
# 类型检查:两个项目均执行 tsc --noEmit(严格模式)
- name: Typecheck (${{ matrix.project.name }})
if: matrix.project.name == 'perler-lab'
working-directory: ${{ matrix.project.name }}
run: npm run typecheck
# 前端生产构建验证(vite build);后端 tsc 编译由 typecheck 覆盖
- name: Frontend production build
if: matrix.project.name == 'perler-lab'
working-directory: perler-lab
run: npm run build
# ── 构建 Docker 镜像(验证 Dockerfile 正确性) ──
build:
needs: test
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
@@ -69,8 +82,12 @@ jobs:
deploy:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
# 需要 GitHub Secrets 配置以下密钥,否则跳过(上一步 build 仍可通过)
if: ${{ secrets.DEPLOY_HOST != '' }}
# 注意:if 条件中不能直接引用 secrets,通过 env 间接判断
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
if: env.DEPLOY_HOST != ''
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.1.0
@@ -88,7 +105,7 @@ jobs:
cd ${{ secrets.DEPLOY_PATH || '/opt/perler-lab' }}
echo "===== 拉取最新代码 ====="
git pull origin main
git pull origin master
echo "===== 构建并启动服务 ====="
docker compose -f perler-lab-server/docker-compose.yml up -d --build