2026-04-19 08:14:25 -03:00
|
|
|
name: BotServer CI
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main]
|
2026-04-24 00:58:00 +00:00
|
|
|
defaults:
|
|
|
|
|
run:
|
|
|
|
|
working-directory: /opt/gbo/work/generalbots
|
2026-04-19 08:14:25 -03:00
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
2026-04-22 13:32:54 +00:00
|
|
|
env:
|
|
|
|
|
CARGO_TARGET_DIR: /opt/gbo/work/target
|
|
|
|
|
RUSTC_WRAPPER: ""
|
|
|
|
|
PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
2026-04-22 13:58:08 +00:00
|
|
|
SYSTEM_HOST: ${{ vars.SYSTEM_HOST }}
|
2026-04-22 21:51:00 -03:00
|
|
|
SYSTEM_USER: gbuser
|
2026-04-19 08:14:25 -03:00
|
|
|
steps:
|
2026-04-24 00:17:45 +00:00
|
|
|
- name: Prepare workspace
|
|
|
|
|
run: |
|
|
|
|
|
mkdir -p /opt/gbo/work/generalbots /opt/gbo/work/target /opt/gbo/bin
|
|
|
|
|
if [ ! -d /opt/gbo/work/generalbots/.git ]; then
|
|
|
|
|
git clone https://alm.pragmatismo.com.br/GeneralBots/generalbots.git /opt/gbo/work/generalbots
|
|
|
|
|
fi
|
2026-04-24 01:28:50 +00:00
|
|
|
cd /opt/gbo/work/generalbots
|
2026-04-23 22:30:14 +00:00
|
|
|
git reset --hard HEAD
|
|
|
|
|
git clean -fd
|
2026-04-22 21:30:26 -03:00
|
|
|
git pull
|
2026-04-23 22:30:14 +00:00
|
|
|
git submodule update --init --recursive
|
2026-04-24 10:01:42 +00:00
|
|
|
- name: Build botui (to embed UI files)
|
2026-04-23 22:30:14 +00:00
|
|
|
run: |
|
2026-04-24 10:01:42 +00:00
|
|
|
cargo build -p botui --bin botui --release
|
|
|
|
|
- name: Build botserver with embedded UI
|
|
|
|
|
run: |
|
|
|
|
|
# Copy botui/ui to botserver/ui so rust-embed can find it
|
|
|
|
|
cp -r botui/ui botserver/ui
|
|
|
|
|
CARGO_BUILD_JOBS=4 cargo build -p botserver --bin botserver --features embed-ui --release
|
2026-04-22 21:30:26 -03:00
|
|
|
- name: Deploy to Stage
|
2026-04-22 01:23:37 +00:00
|
|
|
run: |
|
2026-04-24 10:01:42 +00:00
|
|
|
BINARY=/opt/gbo/work/target/release/botserver
|
2026-04-22 21:51:00 -03:00
|
|
|
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo systemctl stop botserver 2>/dev/null; sudo pkill -x botserver 2>/dev/null; sleep 1"
|
|
|
|
|
scp -o StrictHostKeyChecking=no "$BINARY" ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/bin/botserver-new
|
|
|
|
|
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo systemctl enable botserver && sudo systemctl start botserver"
|
|
|
|
|
sleep 10
|
|
|
|
|
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "curl -sf http://localhost:8080/health && echo 'BotServer Deployed' || echo 'Failed'"
|