Skip to content

Upgrade docker actions #39

Upgrade docker actions

Upgrade docker actions #39

Workflow file for this run

name: Build Docker Images
# There's room for a more sophisticated Docker-image-building apparatus here
# which accommodates the different ROS2 versions using branches.
# But it hurts my head.
on:
push:
branches: [main]
workflow_dispatch:
pull_request:
paths:
- .docker/**
- .github/workflows/docker.yaml
# schedule:
# - cron: "0 17 * * 6"
env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'apl-ocean-engineering/arena_camera_ros2') }}
jobs:
docker_build:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [iron]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Need the docker-container driver to export to cache
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
install: true # Set "docker build" == "docker buildx"
- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#
# Build CI image
#
- name: Docker metadata for build image
if: env.PUSH == 'true'
id: ci_meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}/ci
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}
- name: Build and push the build stage "ci"
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
context: .docker
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ci
tags: ${{ steps.ci_meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
cache-from: type=gha
cache-to: type=gha,mode=max
#
# Build complete image
#
- name: Docker metadata for final image
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-latest
type=raw,value=latest
- name: Build and push full image
uses: docker/[email protected]
with:
context: .docker
file: .docker/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
cache-from: type=gha