501adf7819
- 删除 .gitlab-ci.yml - 新增 .gitea/workflows/deploy.yml (Gitea Actions 工作流) - 新增 deploy/docker/docker-compose.gitea.yml (Gitea + Act Runner) - 更新 scripts/setup-server.sh 初始化脚本 - 更新 deploy/README.md 部署文档 - 更新 Makefile 新增 gitea-* 命令 - 更新 .env.example 新增 GITEA_RUNNER_TOKEN Gitea 内存占用约 100MB,适合 4GB 小内存服务器 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
99 lines
2.6 KiB
YAML
99 lines
2.6 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- prod
|
|
- test
|
|
|
|
env:
|
|
NODE_ENV: production
|
|
|
|
jobs:
|
|
install:
|
|
runs-on: [self-hosted, rent-deploy]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
npm install -g pnpm
|
|
pnpm config set store-dir .pnpm-store
|
|
pnpm install --frozen-lockfile
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
|
|
build:
|
|
runs-on: [self-hosted, rent-deploy]
|
|
needs: install
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Restore pnpm cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
|
|
- name: Build shared packages
|
|
run: |
|
|
npm install -g pnpm
|
|
pnpm config set store-dir .pnpm-store
|
|
pnpm install --frozen-lockfile
|
|
pnpm --filter @rent/shared-types build
|
|
pnpm --filter @rent/shared-utils build
|
|
|
|
- name: Build server
|
|
run: pnpm --filter @rent/server build
|
|
|
|
- name: Build merchant-admin
|
|
run: pnpm --filter @rent/merchant-admin build
|
|
|
|
- name: Build platform-admin
|
|
run: pnpm --filter @rent/platform-admin build
|
|
|
|
- name: Build website
|
|
run: pnpm --filter @rent/official-website build
|
|
|
|
deploy-production:
|
|
runs-on: [self-hosted, rent-deploy]
|
|
needs: build
|
|
if: github.ref == 'refs/heads/prod'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Deploy to production
|
|
run: |
|
|
echo "部署到生产环境..."
|
|
cd deploy/docker
|
|
docker-compose -f docker-compose.prod.yml down --remove-orphans
|
|
docker-compose -f docker-compose.prod.yml build --parallel
|
|
docker-compose -f docker-compose.prod.yml up -d
|
|
docker image prune -f
|
|
echo "等待服务启动..."
|
|
sleep 10
|
|
docker-compose -f docker-compose.prod.yml ps
|
|
|
|
deploy-test:
|
|
runs-on: [self-hosted, rent-deploy]
|
|
needs: build
|
|
if: github.ref == 'refs/heads/test'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Deploy to test
|
|
run: |
|
|
echo "部署到测试环境..."
|
|
cd deploy/docker
|
|
docker-compose -f docker-compose.test.yml down --remove-orphans
|
|
docker-compose -f docker-compose.test.yml build --parallel
|
|
docker-compose -f docker-compose.test.yml up -d
|
|
docker image prune -f
|
|
echo "等待服务启动..."
|
|
sleep 10
|
|
docker-compose -f docker-compose.test.yml ps
|