All checks were successful
BotServer CI/CD / build (push) Successful in 27m5s
73 lines
2.6 KiB
YAML
73 lines
2.6 KiB
YAML
name: BotServer CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
CARGO_BUILD_JOBS: 8
|
|
RUSTC_WRAPPER: sccache
|
|
CARGO_TARGET_DIR: /home/gbuser/workspace/botserver-target
|
|
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
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: gbo
|
|
|
|
steps:
|
|
- name: Setup environment
|
|
run: |
|
|
sccache --start-server 2>/dev/null || true
|
|
|
|
- name: Clone and Build
|
|
run: |
|
|
set -e
|
|
|
|
# Setup project workspace
|
|
mkdir -p ~/workspace/botserver
|
|
cd ~/workspace/botserver
|
|
|
|
# Clone or update repos
|
|
if [ ! -d botlib ]; then
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git
|
|
else
|
|
cd botlib && git pull && cd ..
|
|
fi
|
|
|
|
if [ ! -d botserver/.git ]; then
|
|
rm -rf botserver
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
else
|
|
cd botserver && git pull && cd ..
|
|
fi
|
|
|
|
if [ ! -d ~/workspace/gb-ws ]; then
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git ~/workspace/gb-ws
|
|
else
|
|
cd ~/workspace/gb-ws && git pull && cd ~/workspace/botserver
|
|
fi
|
|
|
|
# Setup Cargo.toml
|
|
cp ~/workspace/gb-ws/Cargo.toml .
|
|
# Remove unwanted members but keep botserver and botlib
|
|
grep -v '"botapp\|"botdevice\|"bottest\|"botui\|"botbook\|"botmodels\|"botplugin\|"bottemplates"' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
|
|
|
|
# Build
|
|
cargo build -p botserver
|
|
sccache --show-stats
|
|
|
|
ls -lh $CARGO_TARGET_DIR/debug/botserver
|
|
|
|
- name: Deploy
|
|
run: |
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
|
ssh $SSH system "sudo systemctl stop botserver || true; sleep 2"
|
|
scp $SSH $CARGO_TARGET_DIR/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 && sudo systemctl start botserver"
|
|
sleep 5
|
|
ssh $SSH system "curl -sf http://localhost:5858/api/health && echo Deployed"
|
|
|
|
- name: Verify
|
|
run: |
|
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
|
ssh $SSH system "pgrep -f botserver && echo Running || echo FAIL"
|