Skip to content

Commit

Permalink
Merge pull request #7 from mascheiber/action/container_build
Browse files Browse the repository at this point in the history
action: add automatic container building
  • Loading branch information
Chris-Bee committed Jul 7, 2023
2 parents 1cf5e93 + 251cd0d commit 5a4858a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 8 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (C) 2022-2023 Martin Scheiber and Christian Brommer,
# Control of Networked Systems, University of Klagenfurt, Austria.
#
# All rights reserved.
#
# This software is licensed under the terms of the BSD-2-Clause-License with
# no commercial use allowed, the full terms of which are made available
# in the LICENSE file. No license in patents is granted.
#
# You can contact the author at <martin.scheiber@ieee.org> and
# <christian.brommer@ieee.org>.

name: Docker Container Build

on:
push:
branches: [ "main", "development" ]
paths:
- 'docker/**'
- '.github/workflows/build-container.yml'

jobs:
build_env:
name: Build Container ${{ github.ref_name }}
runs-on: ubuntu-latest
if: github.repository_owner == 'aau-cns'
env:
IMAGE_URL: aaucns
IMAGE_NAME: mars_ros_test_env
COMMIT_HASH: ${{ github.sha }}
PLATFORMS: "linux/amd64,linux/arm64"
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

# old for internal registry
# - name: Login to Registry
# env:
# DOCKER_USER: ${{ secrets.GITLAB_REGISTRY_USER }}
# DOCKER_PASSWORD: ${{ secrets.GITLAB_REGISTRY_PASSWORD }}
# DOCKER_URL: ${{ secrets.GITLAB_REGISTRY_URL }}
# run: |
# docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD} ${DOCKER_URL}

- name: Login to Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}

- name: Build Docker Image (dev)
if: github.ref == 'refs/heads/development'
run: >
docker buildx build \
--platform=${PLATFORMS} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:dev \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${COMMIT_HASH::6} \
--compress --force-rm --push ./docker/
- name: Build Docker Image (stable)
if: github.ref == 'refs/heads/main'
run: >
docker buildx build \
--platform=${PLATFORMS} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:latest \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${COMMIT_HASH::6} \
--compress --force-rm --push ./docker/
16 changes: 8 additions & 8 deletions .github/workflows/ros.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Martin Scheiber and Christian Brommer,
# Copyright (C) 2022-2023 Martin Scheiber and Christian Brommer,
# Control of Networked Systems, University of Klagenfurt, Austria.
#
# All rights reserved.
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
matrix:
ROS_DISTRO: [noetic, melodic, kinetic]
env:
BADGE_CREATION: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'aau-cns' }}
BADGE_CREATION: ${{ github.event_name == 'push' && github.repository_owner == 'aau-cns' }}
steps:
- name: Create Badge (running)
if: ${{ env.BADGE_CREATION == 'true' }}
Expand All @@ -40,9 +40,9 @@ jobs:
filename: build_mars_ros_${{ matrix.ROS_DISTRO }}.json
label: ${{ matrix.ROS_DISTRO }}
message: running
color: yellow
color: yellowgreen
namedLogo: ROS
style: plastic
style: flat

- name: Get newest Git version
run: >
Expand Down Expand Up @@ -99,9 +99,9 @@ jobs:
filename: build_mars_ros_${{ matrix.ROS_DISTRO }}.json
label: ${{ matrix.ROS_DISTRO }}
message: passing
color: green
color: success
namedLogo: ROS
style: plastic
style: flat

- name: Create Badge (failure)
if: ${{ failure() && env.BADGE_CREATION == 'true' }}
Expand All @@ -114,7 +114,7 @@ jobs:
message: failure
isError: true
namedLogo: ROS
style: plastic
style: flat

- name: Create Badge (cancelled)
if: ${{ cancelled() && env.BADGE_CREATION == 'true' }}
Expand All @@ -127,4 +127,4 @@ jobs:
message: cancelled
color: inactive
namedLogo: ROS
style: plastic
style: flat

0 comments on commit 5a4858a

Please sign in to comment.