refactor: 改用 start.sh 直接部署,去掉 docker compose
This commit is contained in:
@@ -7,48 +7,23 @@ on:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t awesome-index:${{ github.sha }} .
|
||||
docker tag awesome-index:${{ github.sha }} awesome-index:latest
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy to server
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: 114.134.187.170
|
||||
username: root
|
||||
password: ${{ secrets.SERVER_PASSWORD }}
|
||||
script: |
|
||||
# 创建部署目录
|
||||
mkdir -p /app/awesome/data /app/awesome/logs
|
||||
|
||||
- name: Copy files to server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: 114.134.187.170
|
||||
username: root
|
||||
password: ${{ secrets.SERVER_PASSWORD }}
|
||||
source: "docker-compose.yml,start.sh"
|
||||
source: "package.json,package-lock.json,src,public,.env.example,start.sh"
|
||||
target: "/app/awesome/"
|
||||
|
||||
- name: Load and start container
|
||||
- name: Deploy and start service
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: 114.134.187.170
|
||||
@@ -57,14 +32,9 @@ jobs:
|
||||
script: |
|
||||
cd /app/awesome
|
||||
|
||||
# 停止旧容器
|
||||
docker compose down --remove-orphans 2>/dev/null || true
|
||||
# 如不存在 .env 则从 example 复制
|
||||
[ ! -f .env ] && cp .env.example .env
|
||||
|
||||
# 启动新容器
|
||||
docker compose up -d
|
||||
|
||||
# 等待启动
|
||||
sleep 10
|
||||
|
||||
# 健康检查
|
||||
curl -sf http://localhost:3000/healthz && echo " - 服务已启动" || echo " - 启动失败"
|
||||
# 执行启动脚本
|
||||
chmod +x start.sh
|
||||
bash start.sh
|
||||
|
||||
Reference in New Issue
Block a user