Skip to content

Build and upload pbuilder images to Docker hub #1210

Build and upload pbuilder images to Docker hub

Build and upload pbuilder images to Docker hub #1210

name: Build and upload pbuilder images to Docker hub
on:
schedule:
- cron: '0 22 * * *'
push:
paths:
- '.github/workflows/pbuilder-images.yml'
- 'docker/**'
jobs:
build:
strategy:
fail-fast: false
matrix:
dist: [xenial, bionic, focal, jammy, noble, oracular]
arch: [i386, amd64]
exclude:
# No more i386 support since focal
- dist: focal
arch: i386
- dist: jammy
arch: i386
- dist: noble
arch: i386
- dist: oracular
arch: i386
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Build image
run: |
set -x
export TAG="${{ matrix.dist }}-${{ matrix.arch }}"
echo "::group::Login to Docker Hub"
cd docker
docker login -u ${{ secrets.DOCKER_HUB_USER }} -p ${{ secrets.DOCKER_HUB_PWD }}
echo "::endgroup::"
echo "::group::Declare function"
build-image()
{
if [ -f Dockerfile.${{ matrix.dist }} ]
then
cp Dockerfile.${{ matrix.dist }} Dockerfile
fi
sed -i -e's/@ARCH@/${{ matrix.arch }}/' Dockerfile
sed -i -e's/@DIST@/${{ matrix.dist }}/' Dockerfile
sed -i -e's/@ARCH@/${{ matrix.arch }}/' Dockerfile.ros
sed -i -e's/@DIST@/${{ matrix.dist }}/' Dockerfile.ros
sed -i -e's/@ARCH@/${{ matrix.arch }}/' Dockerfile.ros2
sed -i -e's/@DIST@/${{ matrix.dist }}/' Dockerfile.ros2
export ROS_DISTRO=$1
export ROS2_DISTRO=$2
export TAG="${{ matrix.dist }}-${{ matrix.arch }}"
if [ ! -z ${ROS_DISTRO} ]; then
sed -i -e "s/@ROS_DISTRO@/${ROS_DISTRO}/" Dockerfile.ros
export TAG="${TAG}-${ROS_DISTRO}"
cp Dockerfile.ros Dockerfile
fi
if [ ! -z ${ROS2_DISTRO} ]; then
sed -i -e "s/@ROS_DISTRO@/${ROS2_DISTRO}/" Dockerfile.ros2
export TAG="${TAG}-${ROS2_DISTRO}"
cp Dockerfile.ros2 Dockerfile
fi
echo "::group::Build image"
docker build -t gergondet/pbuilder:${TAG} .
echo "::endgroup::"
echo "::group::Upload image"
docker image push gergondet/pbuilder:${TAG}
echo "::endgroup::"
}
echo "::endgroup::"
build-image "" ""
if [ "${{ matrix.dist }}" = "xenial" ]
then
build-image "kinetic" ""
fi
if [ "${{ matrix.dist }}" = "bionic" -a "${{ matrix.arch }}" = "amd64" ]
then
build-image "melodic" ""
fi
if [ "${{ matrix.dist }}" = "focal" ]
then
build-image "noetic" ""
fi
if [ "${{ matrix.dist }}" = "jammy" ]
then
build-image "" "iron"
fi