botserver/.forgejo/workflows/botserver.yaml

103 lines
3.1 KiB
YAML
Raw Normal View History

name: GBCI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_BUILD_JOBS: 2
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
jobs:
build:
runs-on: gbo
steps:
- name: Disable SSL verification
run: git config --global http.sslVerify false
- name: Checkout BotServer Code
uses: actions/checkout@v4
with:
path: botserver
- name: Setup Workspace
run: |
git clone --depth 1 https://alm.pragmatismo.com.br/GeneralBots/gb.git workspace
cd workspace
git submodule update --init --depth 1 botlib
2026-01-25 17:01:02 -03:00
git submodule update --init --depth 1 botui
2026-01-25 17:02:57 -03:00
# Remove missing members from workspace to prevent Cargo errors
sed -i '/"botapp",/d' Cargo.toml
sed -i '/"botdevice",/d' Cargo.toml
sed -i '/"bottest",/d' Cargo.toml
cd ..
rm -rf workspace/botserver
mv botserver workspace/botserver
2026-01-25 17:02:57 -03:00
2025-12-16 16:35:22 -03:00
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
workspace/target
key: ${{ runner.os }}-cargo-v2-debug-${{ hashFiles('**/Cargo.lock') }}
2025-12-16 16:35:22 -03:00
restore-keys: |
${{ runner.os }}-cargo-v2-debug-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev pkg-config
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install sccache
run: |
wget https://github.com/mozilla/sccache/releases/download/v0.8.2/sccache-v0.8.2-x86_64-unknown-linux-musl.tar.gz
tar xzf sccache-v0.8.2-x86_64-unknown-linux-musl.tar.gz
mv sccache-v0.8.2-x86_64-unknown-linux-musl/sccache $HOME/.cargo/bin/sccache
chmod +x $HOME/.cargo/bin/sccache
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_DIR=/opt/gbo/sccache" >> $GITHUB_ENV
- name: Setup environment
run: sudo cp /opt/gbo/bin/system/.env . 2>/dev/null || true
2025-12-18 17:33:04 -03:00
- name: Build debug
working-directory: workspace
run: |
cargo build -p botserver -p botui -j 2 2>&1 | tee /tmp/build.log
2025-12-18 17:33:04 -03:00
ls -lh target/debug/botserver
ls -lh target/debug/botui
2025-12-16 22:29:29 -03:00
- name: Save build log
if: always()
run: |
sudo mkdir -p /opt/gbo/logs
sudo cp /tmp/build.log /opt/gbo/logs/botserver-$(date +%Y%m%d-%H%M%S).log || true
- name: Deploy
working-directory: workspace
run: |
2025-12-16 22:29:29 -03:00
lxc exec bot:pragmatismo-system -- systemctl stop system || true
sudo cp target/debug/botserver /opt/gbo/bin/system/
sudo chmod +x /opt/gbo/bin/system/botserver
sudo cp target/debug/botui /opt/gbo/bin/system/
sudo chmod +x /opt/gbo/bin/system/botui
2025-12-16 22:29:29 -03:00
lxc exec bot:pragmatismo-system -- systemctl start system || true