homepage fix #96
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Server Update | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Install sshpass if needed | |
| run: | | |
| if ! command -v sshpass &> /dev/null; then | |
| echo "sshpass not found, installing..." | |
| sudo apt-get update && sudo apt-get install -y sshpass | |
| fi | |
| - name: Deploy using direct SSH with password | |
| run: | | |
| # 使用sshpass进行密码认证 | |
| sshpass -p "${{ secrets.SERVER_PASSWORD }}" \ | |
| ssh -o StrictHostKeyChecking=no \ | |
| ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \ | |
| -p ${{ secrets.SERVER_PORT }} \ | |
| ' | |
| echo "🚀 正在进入项目目录..." | |
| cd /opt/node/Taco || { echo "❌ 项目目录不存在,请检查路径"; exit 1; } | |
| echo "🔄 正在拉取最新代码..." | |
| git fetch origin main && git reset --hard origin/main | |
| echo "📦 正在进入 Docker 容器 [Taco] 并构建项目..." | |
| docker exec Taco sh -c "pnpm build && rm -rf .next/cache" | |
| echo "🔁 正在重启容器 [Taco]..." | |
| docker restart Taco | |
| echo "✅ 部署完成" | |
| ' |