botserver/.forgejo/workflows/botserver.yaml

81 lines
2.3 KiB
YAML
Raw Normal View History

name: GBCI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_BUILD_JOBS: 1
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C codegen-units=1"
jobs:
build:
runs-on: gbo
steps:
- name: Disable SSL verification (temporary)
run: git config --global http.sslVerify false
- uses: actions/checkout@v4
- name: Clone botlib dependency
2025-12-16 22:29:29 -03:00
run: git clone --depth 1 https://github.com/GeneralBots/botlib.git ../botlib
2025-12-16 16:35:22 -03:00
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-botserver-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-botserver-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
rustc --version
cargo --version
- name: Setup environment
2025-12-16 22:29:29 -03:00
run: sudo cp /opt/gbo/bin/system/.env . || true
- name: Build Linux x86_64
run: |
export PATH="$HOME/.cargo/bin:$PATH"
cargo build --locked 2>&1 | tee /tmp/botserver-build.log
2025-12-16 22:29:29 -03:00
echo "Build exit code: $?"
tail -100 /tmp/botserver-build.log
- name: Save build log
if: always()
run: |
sudo mkdir -p /opt/gbo/logs
sudo cp /tmp/botserver-build.log /opt/gbo/logs/botserver-build-$(date +%Y%m%d-%H%M%S).log || true
sudo tail -200 /tmp/botserver-build.log || true
- name: Prepare release artifacts
run: |
sudo mkdir -p /opt/gbo/releases/botserver/linux
sudo cp ./target/debug/botserver /opt/gbo/releases/botserver/linux/botserver-x86_64 || true
sudo chmod -R 755 /opt/gbo/releases/botserver/
- name: Deploy to production and restart
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/botserver
sudo chmod +x /opt/gbo/bin/system/botserver
2025-12-16 22:29:29 -03:00
lxc exec bot:pragmatismo-system -- systemctl start system || true