- 根目录新增 package.json(workspaces: client、server),两边共用一个 bun.lock, 依赖版本与原来两个 lockfile 完全一致 - 根目录脚本:bun run dev / build / build:staging / test / typecheck / fmt, 取代 dev.sh;client 的 start 改名为 dev,包名改为 webpreview-client - workspaces 用 isolated 安装,补上 client 一直直接 import 却没声明的 @codemirror/view - server 镜像改用仓库根目录做构建上下文,只装 server 的依赖; .dockerignore 用白名单,不再把 node_modules、数据库等发给 docker - CI 在根目录安装并构建前端 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
1.5 KiB
YAML
62 lines
1.5 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: debian
|
|
build_command: build
|
|
remote_port: 22
|
|
# school 暂时停用,需要时恢复(并先按 docs/migrate-to-bun.md 切换那台服务器)
|
|
# - name: school
|
|
# build_command: build:staging
|
|
# remote_port: 8822
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: 1.4.4
|
|
|
|
- name: Build client
|
|
run: |
|
|
bun install --frozen-lockfile --filter webpreview-client
|
|
bun run ${{ matrix.build_command }}
|
|
env:
|
|
CI: false
|
|
|
|
- name: Upload client to ${{ matrix.name }}
|
|
uses: easingthemes/ssh-deploy@main
|
|
with:
|
|
SSH_PRIVATE_KEY: ${{ secrets.KEY }}
|
|
REMOTE_HOST: ${{ secrets.HOST }}
|
|
REMOTE_PORT: ${{ matrix.remote_port }}
|
|
ARGS: "-avzr --delete"
|
|
SOURCE: client/dist/
|
|
REMOTE_USER: root
|
|
TARGET: /root/WebPreview/build
|
|
|
|
- name: Update server on ${{ matrix.name }}
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.HOST }}
|
|
port: ${{ matrix.remote_port }}
|
|
username: root
|
|
key: ${{ secrets.KEY }}
|
|
script: |
|
|
set -e
|
|
cd /root/WebPreview
|
|
git pull --ff-only origin main
|
|
docker compose up -d --build
|