2026-03-21 21:09:49 -03:00
|
|
|
name: BotServer CI/CD
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: ["main"]
|
2026-04-17 18:24:55 -03:00
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
CARGO_BUILD_JOBS: 8
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
|
|
|
|
|
|
|
|
|
steps:
|
2026-04-17 18:47:01 -03:00
|
|
|
- name: Clone and Build
|
2026-04-17 18:24:55 -03:00
|
|
|
run: |
|
2026-04-17 18:47:01 -03:00
|
|
|
set -e
|
|
|
|
|
|
2026-04-17 19:45:18 -03:00
|
|
|
# Setup directories
|
|
|
|
|
mkdir -p ~/workspace ~/cache
|
2026-04-17 18:47:01 -03:00
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
cd ~/workspace
|
2026-04-17 18:47:01 -03:00
|
|
|
|
2026-04-17 19:45:18 -03:00
|
|
|
# Clone or update repos
|
|
|
|
|
if [ ! -d botlib ]; then
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git
|
|
|
|
|
else
|
|
|
|
|
cd botlib && git pull && cd ..
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -d botserver ]; then
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
|
|
|
else
|
|
|
|
|
cd botserver && git pull && cd ..
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -d ~/gb-ws ]; then
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git ~/gb-ws
|
|
|
|
|
else
|
|
|
|
|
cd ~/gb-ws && git pull && cd ~/workspace
|
|
|
|
|
fi
|
2026-04-17 18:47:01 -03:00
|
|
|
|
|
|
|
|
# Setup Cargo.toml
|
2026-04-17 18:45:15 -03:00
|
|
|
cp ~/gb-ws/Cargo.toml ~/workspace/Cargo.toml
|
2026-04-17 18:47:01 -03:00
|
|
|
sed -i '/botapp\|botdevice\|bottest\|botui\|botbook\|botmodels\|botplugin\|bottemplates/d' ~/workspace/Cargo.toml
|
|
|
|
|
|
|
|
|
|
# Build
|
2026-04-17 18:37:22 -03:00
|
|
|
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
2026-04-17 18:47:01 -03:00
|
|
|
export CARGO_TARGET_DIR=~/workspace/target
|
|
|
|
|
cargo build -p botserver
|
2026-04-17 18:37:22 -03:00
|
|
|
|
2026-04-17 18:24:55 -03:00
|
|
|
ls -lh target/debug/botserver
|
|
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
- name: Deploy
|
2026-03-21 20:47:13 -03:00
|
|
|
run: |
|
2026-04-17 18:37:22 -03:00
|
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
|
|
|
|
ssh $SSH system "sudo systemctl stop botserver || true; sleep 2"
|
|
|
|
|
scp $SSH ~/workspace/target/debug/botserver system:/tmp/botserver
|
2026-04-17 18:47:01 -03:00
|
|
|
ssh $SSH system "sudo mv /tmp/botserver /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo chown gbuser:gbuser /opt/gbo/bin/botserver && sudo systemctl start botserver"
|
2026-04-17 18:37:22 -03:00
|
|
|
sleep 5
|
2026-04-17 18:47:01 -03:00
|
|
|
ssh $SSH system "curl -sf http://localhost:5858/api/health && echo Deployed"
|
2026-04-17 12:53:30 -03:00
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
- name: Verify
|
2026-04-17 12:53:30 -03:00
|
|
|
run: |
|
2026-04-17 18:37:22 -03:00
|
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
2026-04-17 18:47:01 -03:00
|
|
|
ssh $SSH system "pgrep -f botserver && echo Running || echo FAIL"
|