CI: Deploy to system container via incus

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-19 06:26:36 -03:00
parent 72e64ce7b4
commit 54e1069ce0

View file

@ -1,4 +1,3 @@
# NEW WORKFLOW - Fresh start
name: BotServer CI
on:
@ -9,26 +8,37 @@ env:
PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
jobs:
deploy:
build:
runs-on: gbo
steps:
- name: Setup
run: |
cd /opt/gbo/work/botserver
git rebase --abort 2>/dev/null || true
git reset --hard HEAD && git clean -fd
git pull
git submodule foreach --recursive git reset --hard HEAD 2>/dev/null || true
git submodule update --init --recursive botlib botserver 2>/dev/null || true
- name: Build
run: |
cd /opt/gbo/work/botserver
cargo build -p botserver
ls -lh target/debug/botserver
- name: Deploy
run: |
echo "Starting deploy..."
# Kill old
timeout 3 bash -c 'while pgrep -x botserver > /dev/null; do pkill -x botserver; sleep 0.3; done' || true
sleep 1
# Copy
cp -f /opt/gbo/work/botserver/target/debug/botserver /opt/gbo/bin/botserver 2>/dev/null || echo "Binary not found, skipping copy"
chmod +x /opt/gbo/bin/botserver
# Start
cd /opt/gbo/bin && ./botserver --noconsole &
sleep 2
BINARY="/opt/gbo/work/botserver/target/debug/botserver"
echo "Deploying from: $BINARY"
# Push binary to system container
sudo incus file push "$BINARY" system:/opt/gbo/bin/botserver --mode=0755
echo "✅ Copied to system container"
# Restart botserver on system container
sudo incus exec system -- systemctl restart botserver
echo "✅ Restarted on system"
# Verify
if pgrep -x botserver > /dev/null 2>&1; then
echo "✅ SUCCESS"
pgrep -x botserver
else
echo "❌ FAILED"
exit 1
fi
sleep 2
sudo incus exec system -- pgrep -x botserver && echo "✅ Running on system!" || echo "❌ Not running"