name: BotUI CI on: push: branches: [main] defaults: run: working-directory: /opt/gbo/work/generalbots jobs: build: runs-on: gbo env: CARGO_TARGET_DIR: /opt/gbo/work/target RUSTC_WRAPPER: "" PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin SYSTEM_HOST: ${{ vars.SYSTEM_HOST }} SYSTEM_USER: gbuser steps: - name: Prepare workspace run: | mkdir -p /opt/gbo/work/generalbots /opt/gbo/work/target /opt/gbo/bin if [ ! -d /opt/gbo/work/generalbots/.git ]; then git clone https://alm.pragmatismo.com.br/GeneralBots/generalbots.git /opt/gbo/work/generalbots fi git reset --hard HEAD git clean -fd git pull mkdir -p /opt/gbo/work/target mkdir -p /opt/gbo/bin - name: Build run: | CARGO_BUILD_JOBS=4 cargo build -p botui --bin botui - name: Deploy run: | BINARY=/opt/gbo/work/target/debug/botui ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo systemctl stop botui 2>/dev/null; sudo pkill -x botui 2>/dev/null; sleep 1" scp -o StrictHostKeyChecking=no "$BINARY" ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/bin/botui-new ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo mv /opt/gbo/bin/botui-new /opt/gbo/bin/botui && sudo chmod +x /opt/gbo/bin/botui && sudo systemctl enable botui && sudo systemctl start botui" sleep 3 ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "pgrep -x botui && echo 'BotUI Deployed' || echo 'Failed'" - name: Sync UI Files to Stage run: | rsync -az --delete -e "ssh -o StrictHostKeyChecking=no" /opt/gbo/work/generalbots/botui/ui/ ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/botui/ui/ rsync -az --delete -e "ssh -o StrictHostKeyChecking=no" /opt/gbo/work/generalbots/botui/ui/ ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/bin/botui/ui/ ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "wc -c /opt/gbo/botui/ui/suite/chat/chat.html /opt/gbo/bin/botui/ui/suite/chat/chat.html 2>/dev/null"