Code cleanup during idle time at CRREL #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker Images | |
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_ros') }} | |
jobs: | |
docker_build: | |
strategy: | |
fail-fast: false | |
matrix: | |
ROS_DISTRO: [noetic] | |
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@v2 | |
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 | |
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: ${{ env.PUSH }} | |
cache-from: type=gha |