@@ -3,6 +3,10 @@ name: Build and publish Ubuntu docker images
33
44on :
55 workflow_dispatch :
6+ push :
7+ paths :
8+ - ' .github/workflows/build_and_publish_ubuntu_docker.yaml'
9+ - ' ros2_ubuntu/**'
610 pull_request :
711 paths :
812 - ' .github/workflows/build_and_publish_ubuntu_docker.yaml'
@@ -52,17 +56,32 @@ jobs:
5256 steps :
5357 - uses : actions/checkout@v6
5458 - uses : docker/setup-buildx-action@v3
59+ - name : Set image tag
60+ id : image_meta
61+ run : |
62+ tag_suffix=""
63+ if [ "${{ github.event_name }}" = "pull_request" ]; then
64+ tag_suffix="-pr-${{ github.event.pull_request.number }}"
65+ fi
66+ if [ "${{ matrix.ros-repo-packages }}" = "-testing" ]; then
67+ echo "image_tag=${{ matrix.ros_distro }}-ubuntu-testing${tag_suffix}" >> "$GITHUB_OUTPUT"
68+ else
69+ echo "image_tag=${{ matrix.ros_distro }}-ubuntu${tag_suffix}" >> "$GITHUB_OUTPUT"
70+ fi
5571 - uses : docker/login-action@v3
5672 with :
5773 registry : ghcr.io
5874 username : ${{ github.repository_owner }}
5975 password : ${{ secrets.GITHUB_TOKEN }}
60- - uses : docker/build-push-action@v6
76+ - name : Build and push image
77+ uses : docker/build-push-action@v6
6178 with :
6279 context : ros2_ubuntu
6380 push : true
6481 file : ros2_ubuntu/Dockerfile
65- tags : ghcr.io/${{ github.repository_owner }}/ros:${{ matrix.ros_distro }}-ubuntu${{ matrix.ros-repo-packages }}
82+ tags : ghcr.io/${{ github.repository_owner }}/ros:${{ steps.image_meta.outputs.image_tag }}
83+ cache-from : type=gha,scope=ubuntu-${{ matrix.ros_distro }}${{ matrix.ros-repo-packages }}
84+ cache-to : type=gha,scope=ubuntu-${{ matrix.ros_distro }}${{ matrix.ros-repo-packages }},mode=max
6685 build-args : |
6786 FROM=${{ matrix.base_image }}
6887 ROS_DISTRO=${{ matrix.ros_distro }}
81100 ros_repo : ${{ matrix.ROS_REPO }}
82101 target_workspace : ros_controls.${{ matrix.ROS_DISTRO }}.repos
83102 ref_for_scheduled_build : master
103+ docker_image_tag_suffix : ${{ github.event_name == 'pull_request' && format('-pr-{0}', github.event.pull_request.number) || '' }}
84104
85105 compatibility-stack-build :
86106 needs : build_images
95115 ros_repo : ${{ matrix.ROS_REPO }}
96116 target_workspace : ros_controls.rolling-on-${{ matrix.ROS_DISTRO }}.repos
97117 ref_for_scheduled_build : master
118+ docker_image_tag_suffix : ${{ github.event_name == 'pull_request' && format('-pr-{0}', github.event.pull_request.number) || '' }}
0 commit comments