name: BotServer CI on: push: branches: [main] paths: - "botserver/**" - "botui/**" - "botlib/**" - ".forgejo/workflows/botserver.yaml" - "Cargo.toml" - "Cargo.lock" jobs: build: runs-on: gbo env: RUSTC_WRAPPER: sccache PATH: "/home/gbuser/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/sbin:/bin" steps: - name: Setup run: | cd /opt/gbo/work/generalbots git stash 2>/dev/null || true OLD_REV=$(git rev-parse HEAD) git pull --rebase || { git rebase --abort; git reset --hard origin/main; } NEW_REV=$(git rev-parse HEAD) if [ "$OLD_REV" != "$NEW_REV" ] then git diff --name-only -z "$OLD_REV" "$NEW_REV" | xargs -0 touch fi git log --oneline -1 - name: Build BotServer and BotUI run: | cd /opt/gbo/work/generalbots rustup default stable export RUSTC_WRAPPER=sccache echo "=== sccache stats before build ===" sccache --show-stats 2>/dev/null || echo "sccache not available" CARGO_BUILD_JOBS=6 cargo build -p botserver --bin botserver CARGO_BUILD_JOBS=6 cargo build -p botui --bin botui --release echo "=== sccache stats after build ===" sccache --show-stats 2>/dev/null || echo "sccache not available" - name: Deploy to Stage run: | echo "=== Deploying to Stage ===" scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ /opt/gbo/work/generalbots/target/debug/botserver \ gbuser@system:/opt/gbo/bin/botserver-new scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ /opt/gbo/work/generalbots/target/release/botui \ gbuser@system:/opt/gbo/bin/botui-new ssh -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ gbuser@system \ "sudo systemctl stop botserver || true && \ sudo systemctl stop ui || true && \ sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && \ sudo mv /opt/gbo/bin/botui-new /opt/gbo/bin/botui && \ sudo chmod +x /opt/gbo/bin/botserver /opt/gbo/bin/botui && \ sudo systemctl start botserver && \ sudo systemctl start ui" sleep 10 ssh -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ gbuser@system \ "curl -sf http://localhost:5858/api/health && echo 'BotServer OK' || echo 'BotServer FAILED'; \ curl -sf http://localhost:3000/ && echo 'BotUI OK' || echo 'BotUI FAILED'"