botui/.forgejo/workflows/botui.yaml

91 lines
3.4 KiB
YAML

name: BotUI CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_BUILD_JOBS: 6
CARGO_NET_RETRY: 10
SCCACHE_DIR: /opt/gbo/cache/sccache
RUSTC_WRAPPER: sccache
CARGO_HOME: /opt/gbo/cache/cargo
jobs:
build:
runs-on: gbo
steps:
- name: Disable SSL verification
run: git config --global http.sslVerify false
- name: Setup Workspace
run: |
mkdir -p /opt/gbo/ci/botui
mkdir -p $SCCACHE_DIR
mkdir -p $CARGO_HOME/registry
# Clone the main gb repository
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/ci/botui/workspace
cd /opt/gbo/ci/botui/workspace
git submodule update --init --depth 1 botlib
# Clone botui separately
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botui.git botui
# Remove all members except botui and botlib from workspace
sed -i '/"botapp",/d' Cargo.toml
sed -i '/"botdevice",/d' Cargo.toml
sed -i '/"bottest",/d' Cargo.toml
sed -i '/"botserver",/d' Cargo.toml
sed -i '/"botbook",/d' Cargo.toml
sed -i '/"botmodels",/d' Cargo.toml
sed -i '/"botplugin",/d' Cargo.toml
sed -i '/"bottemplates",/d' Cargo.toml
- name: Setup PATH for globally installed tools
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Start sccache server
run: |
sccache --start-server || true
sccache --show-stats || true
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev pkg-config
- name: Setup environment
run: sudo cp /opt/gbo/bin/system/.env . 2>/dev/null || true
- name: Build BotUI
working-directory: /opt/gbo/ci/botui/workspace
run: |
cargo build --release -p botui --features embed-ui -j 8 2>&1 | tee /tmp/build.log
ls -lh target/release/botui
sccache --show-stats || true
- name: Save build log
if: always()
run: |
sudo mkdir -p /opt/gbo/logs
sudo cp /tmp/build.log /opt/gbo/logs/botui-$(date +%Y%m%d-%H%M%S).log || true
- name: Setup incus on host
run: |
# SSH to host and setup incus for pushing to containers
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo cp /opt/incus/bin/incus /usr/local/bin/ && sudo chmod +x /usr/local/bin/incus"
- name: Deploy via incus from host
run: |
# SSH to host and deploy via incus
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo incus exec system -- pkill -f /opt/gbo/bin/botui || true"
sleep 2
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo incus exec system -- rm -f /opt/gbo/bin/botui"
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo incus file push /opt/gbo/ci/botui/workspace/target/release/botui system/opt/gbo/bin/botui"
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo incus exec system -- chmod +x /opt/gbo/bin/botui"
ssh -o StrictHostKeyChecking=no administrator@63.141.255.9 "sudo incus exec system -- su - gbuser -c 'cd /opt/gbo/bin && nohup ./botui --noconsole >> /opt/gbo/logs/botui.log 2>&1 &'"