diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..4a95844 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Deploy to Docker + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.DEPLOY_HOST }} + username: ${{ secrets.DEPLOY_USER }} + password: ${{ secrets.DEPLOY_PASSWORD }} + port: 22 + script: | + set -e + APP_DIR="$HOME/mc-ai-bridge" + + # First run: clone. Subsequent: pull. + if [ ! -d "$APP_DIR/.git" ]; then + git clone https://git.silverlabs.uk/SilverLABS/mc-ai-bridge.git "$APP_DIR" + else + cd "$APP_DIR" + git fetch origin main + git reset --hard origin/main + fi + + cd "$APP_DIR" + + # Build and deploy + docker compose down --remove-orphans || true + docker compose build --no-cache + docker compose up -d + + # Verify container is running + sleep 5 + docker compose ps + echo "--- Health check ---" + curl -sf http://localhost:3002/health || echo "Health check not yet available (container may still be starting)"