ci: Use /home/gbuser instead of /opt/gbo/data to avoid permission issues
Some checks failed
BotServer CI/CD / build (push) Failing after 3s

- Move CI workspace to /home/gbuser/persistent-botserver
- Cache now in /home/gbuser/.cache and /home/gbuser/.cargo
- No more permission conflicts with /opt/gbo/data
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-17 12:39:57 -03:00
parent e59892f9b4
commit f67de0e85c

View file

@ -10,46 +10,40 @@ env:
CARGO_BUILD_JOBS: 8 CARGO_BUILD_JOBS: 8
CARGO_NET_RETRY: 10 CARGO_NET_RETRY: 10
RUSTC_WRAPPER: sccache RUSTC_WRAPPER: sccache
SCCACHE_DIR: /opt/gbo/data/cache/sccache SCCACHE_DIR: /home/gbuser/.cache/sccache
CARGO_HOME: /opt/gbo/data/cache/cargo CARGO_HOME: /home/gbuser/.cargo
CARGO_TARGET_DIR: /opt/gbo/data/persistent-botserver/target CARGO_TARGET_DIR: /home/gbuser/persistent-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: jobs:
build: build:
runs-on: gbo runs-on: gbo
steps: steps:
- name: Setup Persistent Directories - name: Setup Workspace
run: | run: |
# Run as root initially to set up directories # Use gbuser home directory instead of /opt/gbo/data
mkdir -p /opt/gbo/data/cache/sccache su - gbuser -c '
mkdir -p /opt/gbo/data/cache/cargo mkdir -p /home/gbuser/.cache/sccache
mkdir -p /opt/gbo/data/persistent-botserver mkdir -p /home/gbuser/.cargo
mkdir -p /opt/gbo/data/gb-ws mkdir -p /home/gbuser/persistent-botserver
chown -R gbuser:gbuser /opt/gbo/data/cache mkdir -p /home/gbuser/gb-ws
chown -R gbuser:gbuser /opt/gbo/data/persistent-botserver '
chown -R gbuser:gbuser /opt/gbo/data/gb-ws
chmod -R 755 /opt/gbo/data/cache
chmod -R 755 /opt/gbo/data/persistent-botserver
chmod -R 755 /opt/gbo/data/gb-ws
- name: Setup Git Config - name: Setup Git
run: | run: |
su - gbuser -c 'git config --global http.sslVerify false' su - gbuser -c 'git config --global http.sslVerify false'
su - gbuser -c 'git config --global --add safe.directory "*"' su - gbuser -c 'git config --global --add safe.directory "*"'
- name: Update Workspace - name: Update Repositories
run: | run: |
set -e set -e
su - gbuser -c ' su - gbuser -c '
WORKSPACE="/opt/gbo/data/persistent-botserver" cd /home/gbuser/persistent-botserver
cd "$WORKSPACE"
# Update botlib # Update botlib
if [ -d botlib/.git ]; then if [ -d botlib/.git ]; then
echo "Updating botlib..." echo "Updating botlib..."
cd botlib && git pull origin main && cd .. (cd botlib && git pull origin main)
else else
echo "Cloning botlib..." echo "Cloning botlib..."
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
@ -58,21 +52,21 @@ jobs:
# Update botserver # Update botserver
if [ -d botserver/.git ]; then if [ -d botserver/.git ]; then
echo "Updating botserver..." echo "Updating botserver..."
cd botserver && git pull origin main && cd .. (cd botserver && git pull origin main)
else else
echo "Cloning botserver..." echo "Cloning botserver..."
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
fi fi
# Update gb workspace # Update gb workspace
if [ -d /opt/gbo/data/gb-ws/.git ]; then if [ -d /home/gbuser/gb-ws/.git ]; then
cd /opt/gbo/data/gb-ws && git pull origin main && cd "$WORKSPACE" (cd /home/gbuser/gb-ws && git pull origin main)
else else
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /home/gbuser/gb-ws
fi fi
# Copy Cargo.toml # Copy Cargo.toml
cp /opt/gbo/data/gb-ws/Cargo.toml Cargo.toml cp /home/gbuser/gb-ws/Cargo.toml Cargo.toml
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do 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 grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
done done
@ -86,53 +80,38 @@ jobs:
dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg" dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg"
done done
if [ -n "$MISSING" ]; then if [ -n "$MISSING" ]; then
apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 apt-get update -qq
apt-get install -y --no-install-recommends $MISSING apt-get install -y --no-install-recommends $MISSING
else
echo "All system dependencies already installed"
fi fi
- name: Clean old artifacts
run: |
su - gbuser -c 'find /opt/gbo/data/persistent-botserver/target -name "*.rlib" -type f -mtime +7 -delete 2>/dev/null || true'
- name: Build BotServer - name: Build BotServer
working-directory: /opt/gbo/data/persistent-botserver working-directory: /home/gbuser/persistent-botserver
run: | run: |
su - gbuser -c " su - gbuser -c '
cd /opt/gbo/data/persistent-botserver cd /home/gbuser/persistent-botserver
sccache --start-server 2>/dev/null || true sccache --start-server 2>/dev/null || true
BOTSERVER_BUILD_DATE=\"$(date -u '+%Y-%m-%dT%H:%M:%SZ')\" echo "Building BotServer..."
BOTSERVER_COMMIT=\"$(su - gbuser -c \"cd /opt/gbo/data/persistent-botserver/botserver && git rev-parse --short HEAD 2>/dev/null || echo unknown\")\"
echo \"Building BotServer (commit: \$BOTSERVER_COMMIT)...\"
cargo build --package botserver 2>&1 | tee /tmp/build.log cargo build --package botserver 2>&1 | tee /tmp/build.log
sccache --stop-server 2>/dev/null || true sccache --stop-server 2>/dev/null || true
" '
continue-on-error: true
- name: Save build log - name: Deploy
run: |
cp /tmp/build.log /tmp/build-output.log 2>/dev/null || true
chown gbuser:gbuser /tmp/build-output.log 2>/dev/null || true
- name: Deploy via SSH to system container
run: | run: |
set -e set -e
su - gbuser -c ' su - gbuser -c '
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5" SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5"
echo "=== Deploy started ==="
echo "Step 1: Stopping botserver..." echo "Stopping botserver..."
ssh $SSH_ARGS system "sudo systemctl stop botserver 2>/dev/null || true; sleep 2; pkill -9 botserver 2>/dev/null || true; echo OK: botserver stopped" ssh $SSH_ARGS system "sudo systemctl stop botserver 2>/dev/null || true; sleep 2"
echo "Step 2: Transferring binary..." echo "Deploying binary..."
scp $SSH_ARGS /opt/gbo/data/persistent-botserver/target/debug/botserver system:/tmp/botserver-new scp $SSH_ARGS /home/gbuser/persistent-botserver/target/debug/botserver system:/tmp/botserver-new
ssh $SSH_ARGS system "sudo mv /tmp/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo chown gbuser:gbuser /opt/gbo/bin/botserver && echo Binary deployed" ssh $SSH_ARGS system "sudo mv /tmp/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo chown gbuser:gbuser /opt/gbo/bin/botserver"
echo "Step 3: Starting botserver..." echo "Starting botserver..."
ssh $SSH_ARGS system "sudo systemctl daemon-reload && sudo systemctl start botserver && echo Botserver started" ssh $SSH_ARGS system "sudo systemctl daemon-reload && sudo systemctl start botserver"
echo "Step 4: Health check..." echo "Health check..."
sleep 5 sleep 5
for i in $(seq 1 30); do for i in $(seq 1 30); do
if ssh $SSH_ARGS system "curl -sf http://localhost:8080/health" 2>/dev/null; then if ssh $SSH_ARGS system "curl -sf http://localhost:8080/health" 2>/dev/null; then
@ -142,18 +121,11 @@ jobs:
echo "waiting ($i/30)..." echo "waiting ($i/30)..."
sleep 2 sleep 2
done done
echo "=== Deploy completed ==="
' '
- name: Verify botserver started - name: Verify
run: | run: |
su - gbuser -c ' su - gbuser -c '
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5" SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo OK: botserver running || echo WARNING: check status" ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo OK || echo FAIL"
' '
- name: Save deploy log
run: |
echo "Deploy completed at $(date)" > /tmp/deploy.log
chown gbuser:gbuser /tmp/deploy.log