feat: 迁移到 Vercel 部署
- 移除 Gitea Actions 配置 - 添加 Vercel 配置文件 - 配置 Serverless 函数路由 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
be29688c85
commit
b88b4d5156
|
|
@ -1,82 +0,0 @@
|
|||
name: Backend CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
# 构建和测试
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 设置 Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: 安装 pnpm
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: 安装依赖
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 代码检查
|
||||
run: |
|
||||
echo "运行代码检查..."
|
||||
# pnpm run lint
|
||||
|
||||
- name: 运行测试
|
||||
run: |
|
||||
echo "运行单元测试..."
|
||||
# pnpm run test
|
||||
|
||||
- name: 构建项目
|
||||
run: pnpm run build
|
||||
|
||||
- name: 上传构建产物
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
retention-days: 1
|
||||
|
||||
# 部署到生产环境
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- name: 拉取最新代码
|
||||
run: |
|
||||
cd /root/self_proj/oauth_nest_demo
|
||||
git pull origin main || git pull origin master
|
||||
|
||||
- name: 重新构建并启动后端容器
|
||||
run: |
|
||||
cd /root/self_proj
|
||||
docker compose up -d --build backend
|
||||
|
||||
- name: 健康检查
|
||||
run: |
|
||||
echo "等待服务启动..."
|
||||
sleep 15
|
||||
curl -f http://localhost:3000/api || exit 1
|
||||
|
||||
- name: 通知部署结果
|
||||
if: always()
|
||||
run: |
|
||||
if [ ${{ job.status }} == 'success' ]; then
|
||||
echo "✅ 后端部署成功!"
|
||||
echo "访问地址: https://tdapi.lcdd.net"
|
||||
else
|
||||
echo "❌ 后端部署失败!"
|
||||
fi
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": 2,
|
||||
"builds": [
|
||||
{
|
||||
"src": "src/main.ts",
|
||||
"use": "@vercel/node"
|
||||
}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"src": "/(.*)",
|
||||
"dest": "src/main.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue