This commit is contained in:
shanshanzhong 2025-09-26 02:14:33 -07:00
parent f35eb48480
commit 993c6d8870

View File

@ -179,6 +179,19 @@ jobs:
if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both' if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both'
run: docker push ${{ env.DOCKER_REGISTRY }}/ppanel/ppanel-user-web:${{ env.VERSION }} run: docker push ${{ env.DOCKER_REGISTRY }}/ppanel/ppanel-user-web:${{ env.VERSION }}
- name: Debug SSH variables
if: env.BUILD_TARGET == 'admin' || env.BUILD_TARGET == 'both'
run: |
echo "SSH_HOST: ${{ env.SSH_HOST }}"
echo "SSH_PORT: ${{ env.SSH_PORT }}"
echo "SSH_USER: ${{ env.SSH_USER }}"
echo "DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}"
echo "VERSION: ${{ env.VERSION }}"
if [ -z "${{ env.SSH_HOST }}" ]; then
echo "ERROR: SSH_HOST is empty!"
exit 1
fi
- name: Deploy Admin via SSH (docker run) - name: Deploy Admin via SSH (docker run)
if: env.BUILD_TARGET == 'admin' || env.BUILD_TARGET == 'both' if: env.BUILD_TARGET == 'admin' || env.BUILD_TARGET == 'both'
uses: https://${{ vars.GIT_USERNAME }}:${{ vars.GIT_PASSWORD }}@${{ env.DOMAIN_URL }}/actions/ssh-action@v0.1.10 uses: https://${{ vars.GIT_USERNAME }}:${{ vars.GIT_PASSWORD }}@${{ env.DOMAIN_URL }}/actions/ssh-action@v0.1.10
@ -192,9 +205,48 @@ jobs:
REG="${{ env.DOCKER_REGISTRY }}" REG="${{ env.DOCKER_REGISTRY }}"
VERSION="${{ env.VERSION }}" VERSION="${{ env.VERSION }}"
echo "Deploying admin: $REG/ppanel/ppanel-admin-web:$VERSION" echo "Deploying admin: $REG/ppanel/ppanel-admin-web:$VERSION"
# 拉取新镜像
docker pull "$REG/ppanel/ppanel-admin-web:$VERSION" || true docker pull "$REG/ppanel/ppanel-admin-web:$VERSION" || true
docker rm -f ppanel-admin-web || true
# 优雅停止并移除容器
if docker ps -q -f name=ppanel-admin-web | grep -q .; then
echo "Stopping existing container..."
docker stop ppanel-admin-web || true
sleep 5
fi
# 移除容器(如果存在)
if docker ps -aq -f name=ppanel-admin-web | grep -q .; then
echo "Removing existing container..."
docker rm ppanel-admin-web || true
fi
# 启动新容器
echo "Starting new container..."
docker run -d --name ppanel-admin-web --restart=always -p 3000:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-admin-web:$VERSION" docker run -d --name ppanel-admin-web --restart=always -p 3000:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-admin-web:$VERSION"
# 验证容器启动
sleep 3
if docker ps -q -f name=ppanel-admin-web | grep -q .; then
echo "Container started successfully"
else
echo "Failed to start container"
exit 1
fi
- name: Debug SSH variables (User)
if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both'
run: |
echo "SSH_HOST: ${{ env.SSH_HOST }}"
echo "SSH_PORT: ${{ env.SSH_PORT }}"
echo "SSH_USER: ${{ env.SSH_USER }}"
echo "DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}"
echo "VERSION: ${{ env.VERSION }}"
if [ -z "${{ env.SSH_HOST }}" ]; then
echo "ERROR: SSH_HOST is empty!"
exit 1
fi
- name: Deploy User via SSH (docker run) - name: Deploy User via SSH (docker run)
if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both' if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both'
@ -209,9 +261,35 @@ jobs:
REG="${{ env.DOCKER_REGISTRY }}" REG="${{ env.DOCKER_REGISTRY }}"
VERSION="${{ env.VERSION }}" VERSION="${{ env.VERSION }}"
echo "Deploying user: $REG/ppanel/ppanel-user-web:$VERSION" echo "Deploying user: $REG/ppanel/ppanel-user-web:$VERSION"
# 拉取新镜像
docker pull "$REG/ppanel/ppanel-user-web:$VERSION" || true docker pull "$REG/ppanel/ppanel-user-web:$VERSION" || true
docker rm -f ppanel-user-web || true
# 优雅停止并移除容器
if docker ps -q -f name=ppanel-user-web | grep -q .; then
echo "Stopping existing container..."
docker stop ppanel-user-web || true
sleep 5
fi
# 移除容器(如果存在)
if docker ps -aq -f name=ppanel-user-web | grep -q .; then
echo "Removing existing container..."
docker rm ppanel-user-web || true
fi
# 启动新容器
echo "Starting new container..."
docker run -d --name ppanel-user-web --restart=always -p 3001:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-user-web:$VERSION" docker run -d --name ppanel-user-web --restart=always -p 3001:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-user-web:$VERSION"
# 验证容器启动
sleep 3
if docker ps -q -f name=ppanel-user-web | grep -q .; then
echo "Container started successfully"
else
echo "Failed to start container"
exit 1
fi
- name: Notify success to Telegram - name: Notify success to Telegram
uses: chapvic/telegram-notify@master uses: chapvic/telegram-notify@master