2026-03-21 21:09:49 -03:00
|
|
|
name: BotServer CI/CD
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: ["main"]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: ["main"]
|
|
|
|
|
|
2025-12-17 21:56:28 -03:00
|
|
|
env:
|
2026-02-06 09:26:44 -03:00
|
|
|
CARGO_BUILD_JOBS: 8
|
2025-12-18 17:14:36 -03:00
|
|
|
CARGO_NET_RETRY: 10
|
2026-04-03 09:40:16 -03:00
|
|
|
RUSTC_WRAPPER: sccache
|
|
|
|
|
WORKSPACE: /opt/gbo/data/botserver
|
|
|
|
|
CARGO_TARGET_DIR: /opt/gbo/data/botserver/target
|
2026-04-03 09:45:02 -03:00
|
|
|
PATH: /home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
2025-12-17 21:56:28 -03:00
|
|
|
|
2025-12-16 13:25:26 -03:00
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
|
|
|
|
|
|
|
|
|
steps:
|
2026-03-31 15:28:11 -03:00
|
|
|
- name: Setup Git
|
2026-03-31 12:15:25 -03:00
|
|
|
run: |
|
|
|
|
|
git config --global http.sslVerify false
|
|
|
|
|
git config --global --add safe.directory "*"
|
2025-12-16 13:25:26 -03:00
|
|
|
|
2026-01-25 12:27:50 -03:00
|
|
|
- name: Setup Workspace
|
|
|
|
|
run: |
|
2026-03-20 21:39:58 -03:00
|
|
|
mkdir -p $WORKSPACE
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
|
# Update or clone botlib
|
|
|
|
|
if [ -d botlib/.git ]; then
|
|
|
|
|
git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
|
|
|
|
fi
|
|
|
|
|
# Update or clone botserver
|
|
|
|
|
if [ -d botserver/.git ]; then
|
|
|
|
|
git -C botserver fetch --depth 1 origin main && git -C botserver checkout FETCH_HEAD
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
|
|
|
fi
|
2026-03-20 21:45:17 -03:00
|
|
|
# Get workspace Cargo.toml from gb and strip unused members
|
2026-04-03 09:40:16 -03:00
|
|
|
if [ -d /opt/gbo/data/gb-ws/.git ]; then
|
|
|
|
|
git -C /opt/gbo/data/gb-ws fetch --depth 1 origin main && git -C /opt/gbo/data/gb-ws checkout FETCH_HEAD
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws
|
|
|
|
|
fi
|
|
|
|
|
cp /opt/gbo/data/gb-ws/Cargo.toml Cargo.toml
|
2026-03-20 21:45:17 -03:00
|
|
|
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
|
|
|
|
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
|
|
|
|
|
done
|
2026-01-25 18:01:19 -03:00
|
|
|
|
2025-12-17 22:40:45 -03:00
|
|
|
- name: Install system dependencies
|
|
|
|
|
run: |
|
2026-04-01 18:19:10 -03:00
|
|
|
PKGS="libpq-dev libssl-dev liblzma-dev pkg-config"
|
|
|
|
|
MISSING=""
|
|
|
|
|
for pkg in $PKGS; do
|
|
|
|
|
dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg"
|
|
|
|
|
done
|
|
|
|
|
if [ -n "$MISSING" ]; then
|
|
|
|
|
sudo apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30
|
|
|
|
|
sudo apt-get install -y --no-install-recommends $MISSING
|
|
|
|
|
else
|
|
|
|
|
echo "All system dependencies already installed"
|
|
|
|
|
fi
|
2025-12-17 22:40:45 -03:00
|
|
|
|
2026-02-05 08:44:21 -03:00
|
|
|
- name: Build BotServer
|
2026-04-03 09:40:16 -03:00
|
|
|
working-directory: /opt/gbo/data/botserver
|
2025-12-16 21:13:12 -03:00
|
|
|
run: |
|
2026-04-03 09:40:16 -03:00
|
|
|
sccache --start-server 2>/dev/null || true
|
2026-03-20 22:44:19 -03:00
|
|
|
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
2026-04-03 09:40:16 -03:00
|
|
|
sccache --show-stats
|
2025-12-18 17:33:04 -03:00
|
|
|
ls -lh target/debug/botserver
|
2025-12-16 22:29:29 -03:00
|
|
|
|
|
|
|
|
- name: Save build log
|
|
|
|
|
if: always()
|
2026-04-03 09:40:16 -03:00
|
|
|
run: cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
2025-12-16 13:25:26 -03:00
|
|
|
|
2026-03-31 19:09:01 -03:00
|
|
|
- name: Deploy via ssh tar gzip
|
2025-12-16 13:25:26 -03:00
|
|
|
run: |
|
2026-03-31 19:09:01 -03:00
|
|
|
set -e
|
2026-04-03 20:01:11 -03:00
|
|
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ServerAliveInterval=5 -o ServerAliveCountMax=2"
|
2026-03-31 18:58:24 -03:00
|
|
|
echo "=== Deploy started ==="
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 1: Checking binary..."
|
2026-04-03 09:40:16 -03:00
|
|
|
ls -lh /opt/gbo/data/botserver/target/debug/botserver
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 2: Killing old botserver..."
|
2026-04-03 20:01:11 -03:00
|
|
|
ssh $SSH_ARGS system "fuser -k -9 /opt/gbo/bin/botserver 2>/dev/null || killall -9 botserver 2>/dev/null || true"
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 3: Removing old binary..."
|
2026-04-03 19:51:30 -03:00
|
|
|
ssh $SSH_ARGS system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 4: Starting tar+gzip transfer..."
|
2026-04-03 19:51:30 -03:00
|
|
|
tar cf - -C /opt/gbo/data/botserver/target/debug botserver | gzip -1 | ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'"
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 5: Verifying transfer..."
|
2026-04-03 19:51:30 -03:00
|
|
|
ssh $SSH_ARGS system "ls -lh /opt/gbo/bin/botserver"
|
2026-03-31 19:09:01 -03:00
|
|
|
echo "Step 6: Setting permissions..."
|
2026-04-03 19:51:30 -03:00
|
|
|
ssh $SSH_ARGS system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver"
|
|
|
|
|
echo "Step 7: Starting botserver..."
|
2026-04-03 20:01:11 -03:00
|
|
|
ssh $SSH_ARGS system "cd /opt/gbo/bin && nohup ./botserver --noconsole > /opt/gbo/logs/stdout.log 2>&1 & disown; echo 'Botserver started'"
|
2026-04-02 17:03:12 -03:00
|
|
|
|
2026-03-21 20:47:13 -03:00
|
|
|
- name: Verify botserver started
|
|
|
|
|
run: |
|
2026-04-03 20:01:11 -03:00
|
|
|
sleep 20
|
|
|
|
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ServerAliveInterval=5 -o ServerAliveCountMax=2"
|
|
|
|
|
ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo 'OK: botserver is running' || (echo 'ERROR: botserver not running' && ssh $SSH_ARGS system 'tail -30 /opt/gbo/logs/stdout.log' && exit 1)"
|
2026-03-21 20:47:13 -03:00
|
|
|
|
2026-03-20 19:51:08 -03:00
|
|
|
- name: Save deploy log
|
|
|
|
|
if: always()
|
2026-04-03 09:40:16 -03:00
|
|
|
run: cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|