2026-03-21 21:09:49 -03:00
|
|
|
name: BotServer CI/CD
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: ["main"]
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
|
|
|
|
|
|
|
|
|
steps:
|
2026-04-17 18:15:40 -03:00
|
|
|
- name: Install deps
|
2025-12-17 22:40:45 -03:00
|
|
|
run: |
|
2026-04-01 18:19:10 -03:00
|
|
|
PKGS="libpq-dev libssl-dev liblzma-dev pkg-config"
|
|
|
|
|
for pkg in $PKGS; do
|
2026-04-17 18:15:40 -03:00
|
|
|
dpkg -s "$pkg" >/dev/null 2>&1 || apt-get install -y "$pkg"
|
|
|
|
|
done || apt-get update && apt-get install -y $PKGS
|
2026-04-17 17:43:04 -03:00
|
|
|
|
2026-04-17 18:15:40 -03:00
|
|
|
- name: Clone
|
2026-04-17 17:43:04 -03:00
|
|
|
run: |
|
2026-04-17 18:15:40 -03:00
|
|
|
cd /tmp
|
|
|
|
|
rm -rf botlib botserver gb-ws
|
|
|
|
|
git clone --depth 1 https://alm.pragmatismo.com.br/GeneralBots/botlib.git
|
|
|
|
|
git clone --depth 1 https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
|
|
|
git clone --depth 1 https://alm.pragmatismo.com.br/GeneralBots/gb.git gb-ws
|
2026-04-03 20:04:31 -03:00
|
|
|
|
2026-04-17 18:15:40 -03:00
|
|
|
- name: Build
|
|
|
|
|
working-directory: /tmp
|
2026-04-17 12:49:13 -03:00
|
|
|
run: |
|
|
|
|
|
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
2026-04-17 18:15:40 -03:00
|
|
|
cp gb-ws/Cargo.toml .
|
|
|
|
|
sed -i '/botapp\|botdevice\|bottest\|botui\|botbook\|botmodels\|botplugin\|bottemplates/d' Cargo.toml
|
|
|
|
|
cargo build --package botserver
|
2026-04-17 12:49:13 -03:00
|
|
|
|
|
|
|
|
- name: Deploy
|
2026-03-21 20:47:13 -03:00
|
|
|
run: |
|
2026-04-17 18:15:40 -03:00
|
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
|
|
|
|
ssh $SSH system "sudo systemctl stop botserver || true"
|
|
|
|
|
scp $SSH /tmp/target/debug/botserver system:/tmp/botserver
|
|
|
|
|
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"
|
|
|
|
|
ssh $SSH system "sudo systemctl start botserver"
|
2026-04-17 12:49:13 -03:00
|
|
|
sleep 5
|
2026-04-17 18:15:40 -03:00
|
|
|
ssh $SSH system "curl -sf http://localhost:8080/api/health && echo 'Deploy OK'"
|
2026-04-17 12:53:30 -03:00
|
|
|
|
|
|
|
|
- name: Verify
|
|
|
|
|
run: |
|
2026-04-17 18:15:40 -03:00
|
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
|
|
|
|
ssh $SSH system "pgrep -f botserver && echo 'BotServer running'"
|