chore: revert to original workflow
Some checks failed
BotServer CI/CD / build (push) Has been cancelled

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-02 15:28:33 -03:00
parent b4acc1f228
commit bd81fb34ec

View file

@ -7,10 +7,8 @@ on:
branches: ["main"] branches: ["main"]
env: env:
CARGO_BUILD_JOBS: 8 CARGO_BUILD_JOBS: 4
CARGO_NET_RETRY: 10 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 PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
jobs: jobs:
@ -23,14 +21,10 @@ jobs:
git config --global http.sslVerify false git config --global http.sslVerify false
git config --global --add safe.directory "*" git config --global --add safe.directory "*"
- name: Install musl target - name: Setup Workspace on host
run: | run: |
rustup target add x86_64-unknown-linux-musl mkdir -p /opt/gbo/ci/botserver
cd /opt/gbo/ci/botserver
- name: Setup Workspace
run: |
mkdir -p $WORKSPACE
cd $WORKSPACE
if [ -d botlib/.git ]; then if [ -d botlib/.git ]; then
git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD
else else
@ -48,54 +42,73 @@ jobs:
done done
rm -rf /tmp/gb-ws rm -rf /tmp/gb-ws
- name: Install system dependencies - name: Transfer source to system container
run: | run: |
PKGS="libpq-dev libssl-dev liblzma-dev pkg-config musl-tools" echo "=== Transferring source to container ==="
MISSING="" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "mkdir -p /opt/gbo/ci/botserver"
for pkg in $PKGS; do tar cf - -C /opt/gbo/ci/botserver botlib botserver Cargo.toml | \
dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=120 -o ServerAliveInterval=10 system "tar xf - -C /opt/gbo/ci/botserver && echo 'Transfer complete'"
done
if [ -n "$MISSING" ]; then
sudo apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30
sudo apt-get install -y --no-install-recommends $MISSING
else
echo "All system dependencies already installed"
fi
- name: Build BotServer (musl static) - name: Install system dependencies in container
working-directory: /opt/gbo/ci/botserver
run: | run: |
cargo build -p botserver --features chat --target x86_64-unknown-linux-musl -j 8 2>&1 | tee /tmp/build.log ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "
ls -lh target/x86_64-unknown-linux-musl/debug/botserver PKGS='libpq-dev libssl-dev liblzma-dev pkg-config'
file target/x86_64-unknown-linux-musl/debug/botserver MISSING=''
for pkg in \$PKGS; do
dpkg -s \"\$pkg\" >/dev/null 2>&1 || MISSING=\"\$MISSING \$pkg\"
done
if [ -n \"\$MISSING\" ]; then
apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30
apt-get install -y --no-install-recommends \$MISSING
else
echo 'All system dependencies already installed'
fi
"
- name: Install Rust in container
run: |
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "
export PATH=/root/.cargo/bin:\$PATH
if ! command -v rustup &>/dev/null || [ \$(rustc --version | grep -oP '\d+\.\d+' | head -1 | cut -d. -f1) -lt 1 ]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
rustc --version
cargo --version
"
- name: Build BotServer inside container
run: |
echo "=== Building inside container ==="
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "
export PATH=/root/.cargo/bin:\$PATH
export CARGO_BUILD_JOBS=4
cd /opt/gbo/ci/botserver
cargo build -p botserver --features chat 2>&1 | tee /tmp/build.log
ls -lh target/debug/botserver
"
- name: Save build log - name: Save build log
if: always() if: always()
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true run: |
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "cat /tmp/build.log" > /tmp/build.log 2>/dev/null || true
sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
- name: Deploy via ssh tar gzip - name: Deploy BotServer
run: | run: |
set -e set -e
echo "=== Deploy started ===" echo "=== Deploy started ==="
echo "Step 1: Checking binary..." echo "Step 1: Killing old botserver..."
ls -lh /opt/gbo/ci/botserver/target/x86_64-unknown-linux-musl/debug/botserver
echo "Step 2: Killing old botserver..."
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "pgrep -f botserver && killall botserver 2>/dev/null || echo 'No running botserver'" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "pgrep -f botserver && killall botserver 2>/dev/null || echo 'No running botserver'"
echo "Step 3: Removing old binary..." echo "Step 2: Copying binary inside container..."
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "
echo "Step 4: Starting tar+gzip transfer..." cp /opt/gbo/ci/botserver/target/debug/botserver /opt/gbo/bin/botserver
tar cf - -C /opt/gbo/ci/botserver/target/x86_64-unknown-linux-musl/debug botserver | gzip -1 | ssh -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=10 system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'" chmod +x /opt/gbo/bin/botserver
echo "Step 5: Verifying transfer..." chown gbuser:gbuser /opt/gbo/bin/botserver
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "ls -lh /opt/gbo/bin/botserver" ls -lh /opt/gbo/bin/botserver
echo "Step 6: Setting permissions..." "
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver"
echo "=== Deploy completed ===" echo "=== Deploy completed ==="
- name: Verify botserver started - name: Verify botserver started
run: | run: |
sleep 10 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)" 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