84 lines
2.7 KiB
YAML
84 lines
2.7 KiB
YAML
#=======================================================================
|
|
# FILE: .gitea/workflows/ci.yml
|
|
# DESC: CI/CD for H100PowerManger
|
|
# - build/test on aarch64 (via QEMU emulation of arm64 Ubuntu 20.04)
|
|
# - deploy the cross-built binary to the RK3588 board
|
|
#=======================================================================
|
|
|
|
name: build-test-deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
|
|
env:
|
|
CI_IMAGE: h100-power-manager-ci:arm64
|
|
|
|
jobs:
|
|
#---------------------------------------------------------------------
|
|
# Build (aarch64) + unit test + startup smoke test
|
|
#---------------------------------------------------------------------
|
|
build-test:
|
|
runs-on: <runner_labels>
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Register QEMU for arm64
|
|
run: |
|
|
docker run --rm --privileged tonistiigi/binfmt --install arm64
|
|
|
|
- name: Build arm64 CI image
|
|
run: |
|
|
docker build -t "$CI_IMAGE" -f ci/Dockerfile .
|
|
|
|
- name: Build & test inside arm64 container
|
|
run: |
|
|
docker run --rm \
|
|
-v "$GITHUB_WORKSPACE:/src" \
|
|
"$CI_IMAGE" /src/ci/build-test.sh
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: arm64-bin
|
|
path: |
|
|
bin/pPowerManger
|
|
bin/pPMtest
|
|
bin/SQLiteTest
|
|
|
|
#---------------------------------------------------------------------
|
|
# Deploy the binary to the RK3588 board (push only, no restart)
|
|
#---------------------------------------------------------------------
|
|
deploy:
|
|
needs: build-test
|
|
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
|
|
runs-on: <runner_labels>
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: arm64-bin
|
|
path: bin/
|
|
|
|
- name: Deploy to board
|
|
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 is 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}/"
|