Move cross_compile workflow to repo root and support manual dispatch
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
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: ${{ github.event_name == 'workflow_dispatch' && fromJSON(format('["{0}"]', inputs.platform)) || fromJSON('["rk3588"]') }}
|
||||
ros_distro: ${{ github.event_name == 'workflow_dispatch' && fromJSON(format('["{0}"]', inputs.ros_distro)) || fromJSON('["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 -f cross_compile/compose.yaml 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 -f cross_compile/compose.yaml 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 -f cross_compile/compose.yaml 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 -f cross_compile/compose.yaml 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
|
||||
Reference in New Issue
Block a user