Skip to content

Build and publish RHEL docker images #179

Build and publish RHEL docker images

Build and publish RHEL docker images #179

---
name: Build and publish RHEL docker images
on:
workflow_dispatch:
push:
branches:
- master
paths:
- '.github/workflows/build_and_publish_rhel_docker.yaml'
- 'ros2_rhel/**'
pull_request:
paths:
- '.github/workflows/build_and_publish_rhel_docker.yaml'
- 'ros2_rhel/**'
schedule:
- cron: '1 0 * * MON'
concurrency:
# cancel previous runs of the same workflow, except for pushes on given branches
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/heads') }}
jobs:
build_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- ros_distro: humble
rhel_version: rhel8
source_packages: ""
- ros_distro: jazzy
rhel_version: rhel9
source_packages: pinocchio
- ros_distro: kilted
rhel_version: rhel9
source_packages: pinocchio
- ros_distro: lyrical
rhel_version: rhel10
source_packages: pinocchio
- ros_distro: rolling
rhel_version: rhel10
source_packages: pinocchio
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- name: Set image tag
id: image_meta
run: |
tag_suffix=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
tag_suffix="-pr-${{ github.event.pull_request.number }}"
fi
echo "image_tag=${{ matrix.ros_distro }}-rhel${tag_suffix}" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v7
with:
context: ros2_rhel
push: true
provenance: false
sbom: false
file: ros2_rhel/Dockerfile.${{ matrix.rhel_version }}
tags: ghcr.io/${{ github.repository_owner }}/ros:${{ steps.image_meta.outputs.image_tag }}
labels: |
org.opencontainers.image.source=https://github.com/ros-controls/ros2_control_ci
org.opencontainers.image.description=${{ matrix.rhel_version }} for ros-controls CI
org.opencontainers.image.licenses=Apache-2.0
cache-from: ${{ github.event_name != 'schedule' && format('type=gha,scope=rhel-{0}', matrix.ros_distro) || '' }}
cache-to: type=gha,scope=rhel-${{ matrix.ros_distro }},mode=max
build-args: |
ROS_DISTRO=${{ matrix.ros_distro }}
SOURCE_PACKAGES=${{ matrix.source_packages }}
stack-build:
if: ${{ github.event_name == 'pull_request' }}
needs: build_images
uses: ./.github/workflows/reusable-rhel-binary-build.yml
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling, humble, jazzy, kilted, lyrical]
with:
ros_distro: ${{ matrix.ROS_DISTRO }}
target_workspace: ros_controls.${{ matrix.ROS_DISTRO }}.repos
skip_packages_regex: '^mujoco_ros2_control.*$|^gz_ros2_control.*$|^ros2_control_demo_example_9$|^ros2_control_demos$|^ign_ros2_control.*$'
ref_for_scheduled_build: master
docker_image_tag_suffix: ${{ format('-pr-{0}', github.event.pull_request.number) }}