Some checks failed
BotServer CI/CD / build (push) Failing after 7s
95 lines
4 KiB
YAML
95 lines
4 KiB
YAML
name: BotServer CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
CARGO_BUILD_JOBS: 8
|
|
CARGO_NET_RETRY: 10
|
|
WORKSPACE: /opt/gbo/ci/botserver
|
|
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
|
|
PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: gbo
|
|
|
|
steps:
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global http.sslVerify false
|
|
git config --global --add safe.directory "*"
|
|
|
|
- name: Setup Workspace
|
|
run: |
|
|
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
|
|
# 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
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev pkg-config
|
|
|
|
- name: Build BotServer
|
|
working-directory: /opt/gbo/ci/botserver
|
|
run: |
|
|
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
|
ls -lh target/debug/botserver
|
|
|
|
- name: Save build log
|
|
if: always()
|
|
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
|
|
|
- name: Deploy via ssh tar zstd
|
|
run: |
|
|
echo "=== Deploy started ==="
|
|
echo "Checking binary exists..."
|
|
ls -lh /opt/gbo/ci/botserver/target/debug/botserver
|
|
echo "Testing SSH to system..."
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "echo SSH OK && pkill -f botserver || true"
|
|
echo "Removing old binary..."
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
|
echo "Starting tar+zstd transfer..."
|
|
tar czf - -C /opt/gbo/ci/botserver/target/debug botserver | ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -o ServerAliveInterval=15 system "tar xzf - -C /opt/gbo/bin && echo 'Transfer complete'" 2>&1 | tee /tmp/deploy.log
|
|
TRANSFER_EXIT=${PIPESTATUS[0]}
|
|
echo "Transfer exit code: $TRANSFER_EXIT"
|
|
if [ "$TRANSFER_EXIT" != "0" ]; then
|
|
echo "Transfer FAILED with exit code $TRANSFER_EXIT"
|
|
exit 1
|
|
fi
|
|
echo "Transfer SUCCESS, setting permissions..."
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && ls -lh /opt/gbo/bin/botserver"
|
|
echo "Starting botserver..."
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "cd /opt/gbo/bin && sudo -u gbuser ./botserver --noconsole >> /opt/gbo/logs/error.log 2>&1 &"
|
|
echo "=== Deploy completed ==="
|
|
|
|
- name: Verify botserver started
|
|
run: |
|
|
sleep 10
|
|
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)"
|
|
|
|
- name: Save deploy log
|
|
if: always()
|
|
run: sudo cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|