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
|
|
|
|
|
CARGO_NET_RETRY: 10
|
|
|
|
|
RUSTC_WRAPPER: sccache
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
|
|
|
|
|
|
|
|
|
steps:
|
2026-04-17 18:37:22 -03:00
|
|
|
- name: Setup Directories
|
2026-04-17 18:24:55 -03:00
|
|
|
run: |
|
2026-04-17 18:37:22 -03:00
|
|
|
mkdir -p ~/cache/sccache
|
|
|
|
|
mkdir -p ~/workspace/target
|
|
|
|
|
mkdir -p ~/gb-ws
|
2026-04-17 18:24:55 -03:00
|
|
|
|
|
|
|
|
- name: Setup Git
|
|
|
|
|
run: |
|
|
|
|
|
git config --global http.sslVerify false
|
|
|
|
|
git config --global --add safe.directory "*"
|
|
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
- name: Clone Sources (Fresh)
|
2026-04-17 18:24:55 -03:00
|
|
|
run: |
|
2026-04-17 18:37:22 -03:00
|
|
|
cd ~/workspace
|
2026-04-17 18:45:15 -03:00
|
|
|
rm -rf botlib botserver
|
2026-04-17 18:37:22 -03:00
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
2026-04-17 18:24:55 -03:00
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
rm -rf ~/gb-ws
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git ~/gb-ws
|
2026-04-17 18:45:15 -03:00
|
|
|
|
|
|
|
|
- name: Setup Cargo.toml
|
|
|
|
|
working-directory: /home/gbuser/workspace
|
|
|
|
|
run: |
|
|
|
|
|
cp ~/gb-ws/Cargo.toml ~/workspace/Cargo.toml
|
2026-04-17 18:24:55 -03:00
|
|
|
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
2026-04-17 18:45:15 -03:00
|
|
|
grep -v "\"$m\"" ~/workspace/Cargo.toml > /tmp/c.toml && mv /tmp/c.toml ~/workspace/Cargo.toml
|
2026-04-17 18:24:55 -03:00
|
|
|
done
|
2026-04-17 18:45:15 -03:00
|
|
|
ls -la ~/workspace/Cargo.toml
|
2026-04-17 18:24:55 -03:00
|
|
|
|
2026-04-17 18:37:22 -03:00
|
|
|
- name: Build BotServer
|
|
|
|
|
working-directory: /home/gbuser/workspace
|
2026-04-17 12:49:13 -03:00
|
|
|
run: |
|
2026-04-17 18:37:22 -03:00
|
|
|
export SCCACHE_DIR=~/cache/sccache
|
|
|
|
|
export CARGO_TARGET_DIR=~/workspace/target
|
|
|
|
|
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
|
|
|
|
|
2026-04-17 18:24:55 -03:00
|
|
|
sccache --start-server 2>/dev/null || true
|
2026-04-17 18:37:22 -03:00
|
|
|
cargo build -p botserver -j 8
|
2026-04-17 18:24:55 -03:00
|
|
|
sccache --show-stats
|
|
|
|
|
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:24:55 -03:00
|
|
|
set -e
|
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
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
for i in $(seq 1 30); do
|
|
|
|
|
ssh $SSH system "curl -sf http://localhost:5858/api/health" && echo "OK" && break
|
|
|
|
|
echo "wait $i/30"
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
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"
|
|
|
|
|
ssh $SSH system "pgrep -f botserver && echo 'Running' || echo 'FAIL'"
|