Files
H100PowerManger/.gitea/workflows/ci.yml
T
2026-08-14 13:08:06 +08:00

84 lines
3.5 KiB
YAML

#=======================================================================
# FILE: .gitea/workflows/ci.yml
# DESC: CI/CD for H100PowerManger
# - build/test on aarch64 (QEMU emulation of arm64 Ubuntu 20.04)
# - deploy the cross-built binary to the RK3588 board
# NOTE: self-contained (no external actions), runner host needs
# Docker + internet to pull images + privileged for QEMU.
#=======================================================================
name: build-test-deploy
on:
push:
branches: [main]
tags: ['v*']
pull_request:
env:
CI_IMAGE: h100-power-manager-ci:arm64
GITEA_SERVER: ${{ vars.GITEA_SERVER_URL }}
jobs:
ci:
runs-on: <runner_labels>
steps:
#-------------------------------------------------------------------
# Checkout via git (no external actions/checkout dependency)
#-------------------------------------------------------------------
- name: Checkout
run: |
set -euo pipefail
SERVER="${GITEA_SERVER:-https://gitea2.zhaojingkui.xyz}"
REPO_URL="${SERVER}/zjk/H100PowerManger.git"
git init .
git remote add origin "https://zjk:${{ secrets.CI_TOKEN }}@$(echo "${REPO_URL}" | sed 's|^https://||')"
git fetch --depth 1 origin "$GITHUB_SHA"
git checkout FETCH_HEAD
#-------------------------------------------------------------------
# Register QEMU so arm64 binaries/images can run on the x86 runner
#-------------------------------------------------------------------
- name: Register QEMU for arm64
run: |
docker run --rm --privileged tonistiigi/binfmt --install arm64
#-------------------------------------------------------------------
# Build the aarch64 CI image (MOOS-IvP + jsoncpp)
#-------------------------------------------------------------------
- name: Build arm64 CI image
run: |
docker build -t "$CI_IMAGE" -f ci/Dockerfile .
#-------------------------------------------------------------------
# Build project + unit test + startup smoke test (inside arm64)
#-------------------------------------------------------------------
- name: Build & test inside arm64 container
run: |
docker run --rm \
-v "$GITHUB_WORKSPACE:/src" \
"$CI_IMAGE" /src/ci/build-test.sh
#-------------------------------------------------------------------
# Deploy the cross-built binary to the RK3588 board (push only)
#-------------------------------------------------------------------
- name: Deploy to board
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
set -euo pipefail
USER="${DEPLOY_USER:-root}"
HOST="${DEPLOY_HOST:?DEPLOY_HOST secret not set}"
DEST="${DEPLOY_PATH:-/root/work/moos_ws/moos-ivp-extend/bin}"
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts 2>/dev/null
chmod 755 bin/pPowerManger
rsync -avz bin/pPowerManger "${USER}@${HOST}:${DEST}/pPowerManger"
echo "Deployed pPowerManger -> ${USER}@${HOST}:${DEST}/"