bc5de267f7
Create a CI pipeline that builds and optionally pushes Docker images for cross-compilation targets (rk3588) and ROS 2 distributions, with multi-stage builds for base, toolchain, vendor packages, and ROS 2. Also ignore diagnostic_remote_logging package in the Lyrical ROS 2 build.
130 lines
5.0 KiB
YAML
130 lines
5.0 KiB
YAML
name: Build Cross-Compiled ROS 2 Images
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "**.md"
|
|
- ".github/ISSUE_TEMPLATE/**"
|
|
- ".github/pull_request_template.md"
|
|
pull_request:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "**.md"
|
|
- ".github/ISSUE_TEMPLATE/**"
|
|
- ".github/pull_request_template.md"
|
|
workflow_dispatch:
|
|
inputs:
|
|
platform:
|
|
description: "Target platform"
|
|
required: true
|
|
type: choice
|
|
options: [rk3588]
|
|
default: rk3588
|
|
ros_distro:
|
|
description: "ROS 2 distribution"
|
|
required: true
|
|
type: choice
|
|
options: [rolling, jazzy, lyrical]
|
|
default: lyrical
|
|
push_images:
|
|
description: "Push built images to registry"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAMESPACE: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
platform: [rk3588]
|
|
ros_distro: [rolling]
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: |
|
|
network=host
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_images)
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# ── Stage 1: Build base image ──────────────────────────────────────
|
|
- name: Build cc-base
|
|
run: |
|
|
docker compose build cc-base
|
|
|
|
- name: Push cc-base
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_images)
|
|
run: |
|
|
docker tag cc-base:latest \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/cc-base:latest
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/cc-base:latest
|
|
|
|
# ── Stage 2: Build toolchain image per platform ────────────────────
|
|
- name: Build cc-toolchain (${{ matrix.platform }})
|
|
run: |
|
|
PLATFORM=${{ matrix.platform }} docker compose build cc-toolchain
|
|
env:
|
|
BUILDKIT_INLINE_CACHE: "1"
|
|
|
|
- name: Push cc-toolchain
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_images)
|
|
run: |
|
|
docker tag ${{ matrix.platform }}/cc-toolchain:latest \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-toolchain:latest
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-toolchain:latest
|
|
|
|
# ── Stage 3: Build vendor packages ─────────────────────────────────
|
|
- name: Build vendor-packages (${{ matrix.platform }})
|
|
run: |
|
|
PLATFORM=${{ matrix.platform }} docker compose build vendor-packages
|
|
env:
|
|
BUILDKIT_INLINE_CACHE: "1"
|
|
|
|
- name: Push vendor-packages
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_images)
|
|
run: |
|
|
docker tag ${{ matrix.platform }}/cc-vendor-packages:latest \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-vendor-packages:latest
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-vendor-packages:latest
|
|
|
|
# ── Stage 4: Build ROS 2 per distro ────────────────────────────────
|
|
- name: Build ROS 2 (${{ matrix.ros_distro }})
|
|
run: |
|
|
PLATFORM=${{ matrix.platform }} ROS_DISTRO=${{ matrix.ros_distro }} docker compose build ros2
|
|
env:
|
|
BUILDKIT_INLINE_CACHE: "1"
|
|
|
|
- name: Push ROS 2 image
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_images)
|
|
run: |
|
|
docker tag ${{ matrix.platform }}/cc-ros-${{ matrix.ros_distro }}:latest \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-ros-${{ matrix.ros_distro }}:latest
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.platform }}/cc-ros-${{ matrix.ros_distro }}:latest
|
|
|
|
# ── Summary ───────────────────────────────────────────────────────
|
|
- name: Image summary
|
|
if: always()
|
|
run: |
|
|
echo "### Built Images :rocket:" >> $GITHUB_STEP_SUMMARY
|
|
docker images \
|
|
--filter "reference=cc-*" \
|
|
--format "| \`{{.Repository}}:{{.Tag}}\` | {{.Size}} |" \
|
|
>> $GITHUB_STEP_SUMMARY
|