feat: 更新 CI/CD 配置为本地部署
- 移除 SSH 远程部署方式 - 改为本地直接执行 Docker 命令 - 优化健康检查等待时间 - 添加部署成功后的访问地址提示 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
65a8c53176
commit
7cd5ba6933
|
|
@ -55,40 +55,28 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 拉取最新代码
|
||||||
uses: actions/checkout@v3
|
run: |
|
||||||
|
cd /root/self_proj/oauth_nest_demo
|
||||||
|
git pull origin main || git pull origin master
|
||||||
|
|
||||||
- name: 下载构建产物
|
- name: 重新构建并启动后端容器
|
||||||
uses: actions/download-artifact@v3
|
run: |
|
||||||
with:
|
cd /root/self_proj
|
||||||
name: dist
|
docker-compose up -d --build backend
|
||||||
path: dist/
|
|
||||||
|
|
||||||
- name: 部署到服务器
|
|
||||||
uses: appleboy/ssh-action@master
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.SERVER_HOST }}
|
|
||||||
username: ${{ secrets.SERVER_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
port: ${{ secrets.SERVER_PORT || 22 }}
|
|
||||||
script: |
|
|
||||||
cd /root/self_proj/oauth_nest_demo
|
|
||||||
git pull origin main
|
|
||||||
cd /root/self_proj
|
|
||||||
docker-compose up -d --build backend
|
|
||||||
docker-compose ps
|
|
||||||
|
|
||||||
- name: 健康检查
|
- name: 健康检查
|
||||||
run: |
|
run: |
|
||||||
echo "等待服务启动..."
|
echo "等待服务启动..."
|
||||||
sleep 10
|
sleep 15
|
||||||
curl -f http://${{ secrets.SERVER_HOST }}:3000/api || exit 1
|
curl -f http://localhost:3000/api || exit 1
|
||||||
|
|
||||||
- name: 通知部署结果
|
- name: 通知部署结果
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
if [ ${{ job.status }} == 'success' ]; then
|
if [ ${{ job.status }} == 'success' ]; then
|
||||||
echo "✅ 后端部署成功!"
|
echo "✅ 后端部署成功!"
|
||||||
|
echo "访问地址: https://tdapi.lcdd.net"
|
||||||
else
|
else
|
||||||
echo "❌ 后端部署失败!"
|
echo "❌ 后端部署失败!"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue