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-03-20 21:39:58 -03:00
|
|
|
WORKSPACE: /opt/gbo/ci/botserver
|
|
|
|
|
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
|
2026-03-31 15:32:37 -03:00
|
|
|
PATH: /root/.cargo/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
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws
|
|
|
|
|
cp /tmp/gb-ws/Cargo.toml Cargo.toml
|
|
|
|
|
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
|
|
|
|
|
rm -rf /tmp/gb-ws
|
2026-01-25 18:01:19 -03:00
|
|
|
|
2025-12-17 22:40:45 -03:00
|
|
|
- name: Install system dependencies
|
|
|
|
|
run: |
|
2026-03-17 13:12:41 -03:00
|
|
|
sudo apt-get update -qq
|
2025-12-18 17:14:36 -03:00
|
|
|
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev pkg-config
|
2025-12-17 22:40:45 -03:00
|
|
|
|
2026-02-05 08:44:21 -03:00
|
|
|
- name: Build BotServer
|
2026-03-20 21:39:58 -03:00
|
|
|
working-directory: /opt/gbo/ci/botserver
|
2025-12-16 21:13:12 -03:00
|
|
|
run: |
|
2026-03-20 22:44:19 -03:00
|
|
|
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
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-03-17 13:12:41 -03:00
|
|
|
run: sudo 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 18:16:56 -03:00
|
|
|
- name: Deploy via rsync
|
2025-12-16 13:25:26 -03:00
|
|
|
run: |
|
2026-03-31 18:58:24 -03:00
|
|
|
echo "=== Deploy started ==="
|
|
|
|
|
echo "Checking binary exists..."
|
|
|
|
|
ls -lh /opt/gbo/ci/botserver/target/debug/botserver
|
|
|
|
|
echo "Killing old botserver..."
|
|
|
|
|
ssh -o StrictHostKeyChecking=no system "pkill -f botserver || true; sleep 2; rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
|
|
|
|
echo "Starting rsync transfer..."
|
|
|
|
|
rsync -avz --progress -e "ssh -o StrictHostKeyChecking=no -v" /opt/gbo/ci/botserver/target/debug/botserver system:/opt/gbo/bin/botserver 2>&1 | tee /tmp/deploy.log
|
|
|
|
|
RSYNC_EXIT=${PIPESTATUS[0]}
|
|
|
|
|
echo "rsync exit code: $RSYNC_EXIT"
|
|
|
|
|
if [ "$RSYNC_EXIT" != "0" ]; then
|
|
|
|
|
echo "rsync FAILED with exit code $RSYNC_EXIT"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
echo "rsync SUCCESS, setting permissions..."
|
|
|
|
|
ssh -o StrictHostKeyChecking=no system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && ls -lh /opt/gbo/bin/botserver && cd /opt/gbo/bin && nohup sudo -u gbuser ./botserver --noconsole >> /opt/gbo/logs/error.log 2>&1 &"
|
|
|
|
|
echo "=== Deploy completed ==="
|
2026-03-20 19:51:08 -03:00
|
|
|
|
2026-03-21 20:47:13 -03:00
|
|
|
- name: Verify botserver started
|
|
|
|
|
run: |
|
|
|
|
|
sleep 10
|
2026-03-31 12:15:25 -03:00
|
|
|
ssh -o StrictHostKeyChecking=no system "pgrep -f botserver && echo 'OK: botserver is running' || (echo 'ERROR: botserver not running' && cat /opt/gbo/logs/error.log | tail -20 && exit 1)"
|
2026-03-21 20:47:13 -03:00
|
|
|
|
2026-03-20 19:51:08 -03:00
|
|
|
- name: Save deploy log
|
|
|
|
|
if: always()
|
|
|
|
|
run: sudo cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|