Skip to content

Commit

Permalink
Update deployment workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lmark1 committed Dec 22, 2023
1 parent 6e23964 commit 02149b9
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 163 deletions.
52 changes: 27 additions & 25 deletions .github/workflows/melodic.yml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
# This is a basic workflow to help you get started with Actions

name: Melodic
name: Binary Deployment

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/HOWTO.md'
- '**/DEVELOPMENT.md'
- '**/FAQ.md'
pull_request:
branches: [ main ]

schedule:
- cron: '0 0 * * *' # at the end of every day

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
tags:
- '[v]?[0-9]+.[0-9]+.[0-9]+'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -34,29 +21,44 @@ jobs:
access_token: ${{ github.token }}

deploy:

# The type of runner that the job will run on
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: cancel
if: github.event_name != 'pull_request'
strategy:
matrix:
distro: [bionic, focal]
steps:
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
with:
file: Dockerfile.bionic
push: true
tags: lmark1/uav_ros_simulation:bionic
file: Dockerfile.binary
push: true
tags: lmark1/uav_ros_simulation:${{ matrix.distro }}-bin-${{ github.ref_name }}
build-args: |
DISTRO=${{ matrix.distro }}
VERSION=${{ github.ref_name }}
--ssh=default
89 changes: 42 additions & 47 deletions .github/workflows/noetic.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Noetic
name: CI/CD

# Controls when the action will run.
on:
Expand All @@ -9,15 +9,10 @@ on:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/HOWTO.md'
- '**/DEVELOPMENT.md'
- '**/FAQ.md'
pull_request:
branches: [ main ]

schedule:
- cron: '0 0 * * *' # at the end of every day

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -35,20 +30,33 @@ jobs:

# This workflow contains a single job called "build"
build:

# The type of runner that the job will run on
runs-on: ubuntu-20.04
needs: cancel

env:
CATKIN_WORKSPACE: uav_ws

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch the whole history

# Use ssh key in private repository
# https://www.webfactory.de/blog/use-ssh-key-for-private-repositories-in-github-actions
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
# Runs a single command using the runners shell
- name: Install
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: ./.ci/ci_before_install.sh

# Runs a set of commands using the runners shell
Expand All @@ -60,57 +68,44 @@ jobs:
run: ./.ci/ci_run_tests.sh

deploy:

# The type of runner that the job will run on
runs-on: ubuntu-20.04
needs: build
if: github.event_name != 'pull_request'
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
file: Dockerfile.focal
push: true
tags: lmark1/uav_ros_simulation:focal

deploy-nogpu:

# The type of runner that the job will run on
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
strategy:
matrix:
distro: [bionic, focal]
steps:
# Use ssh key in private repository
# https://www.webfactory.de/blog/use-ssh-key-for-private-repositories-in-github-actions
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
username: ${{ secrets.DOCKERHUB_USERNAME2 }}
password: ${{ secrets.DOCKERHUB_PASSWORD2 }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
with:
file: Dockerfile.focal-nogpu
file: Dockerfile.source
push: true
tags: lmark1/uav_ros_simulation:focal-nogpu
tags: lmark2/uav_ros_simulation_source:${{ matrix.distro }}
build-args: |
DISTRO=${{ matrix.distro }}
--ssh=default
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Changelog
=========

Upcoming
--------------
- TODO

v0.0.1 (22-12-2023)
--------------

- Initial Release
9 changes: 6 additions & 3 deletions Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM lmark1/uav_ros_stack:focal-bin-0.0.1
ARG VERSION=0.0.1
ARG DISTRO=focal

FROM lmark1/uav_ros_stack:$DISTRO-bin-$VERSION

# https://blog.alexellis.io/mutli-stage-docker-builds/ - Neat!
FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04
# FROM ubuntu:focal
# FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04
FROM ubuntu:$DISTRO

# Use ARG - persists only during docker build
# https://github.com/moby/moby/issues/4032#issuecomment-192327844
Expand Down
42 changes: 0 additions & 42 deletions Dockerfile.bionic

This file was deleted.

41 changes: 0 additions & 41 deletions Dockerfile.focal-nogpu

This file was deleted.

10 changes: 7 additions & 3 deletions Dockerfile.focal → Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04
# Use ARG - persists only during docker build
# https://github.com/moby/moby/issues/4032#issuecomment-192327844
ARG CATKIN_WORKSPACE=uav_ws
ARG DEBIAN_FRONTEND=noninteractive
ARG HOME=/root
ARG USER=root
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Install all the things to stop docker build from breaking
RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \
Expand All @@ -21,10 +22,13 @@ RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \
keyboard-configuration && \
dpkg-reconfigure --frontend noninteractive tzdata

# download public key for github.com
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

# Install uav_ros_simulation and setup catkin workspace
WORKDIR $HOME
RUN git clone https://github.com/larics/uav_ros_simulation.git
RUN ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE
RUN --mount=type=ssh git clone git@github.com:larics/uav_ros_simulation.git
RUN --mount=type=ssh ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE

# Build catkin workspace
WORKDIR $HOME/$CATKIN_WORKSPACE/src
Expand Down
4 changes: 2 additions & 2 deletions run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo "Running Docker Container"
CONTAINER_NAME=uav_ros_simulation

# Get distro of the built image
distro="focal"
distro="focal-bin-0.0.1"
run_args=""

for (( i=1; i<=$#; i++));
Expand Down Expand Up @@ -64,5 +64,5 @@ docker run \
--env DISPLAY=$DISPLAY \
--env TERM=xterm-256color \
--name $full_container_name \
lmark1/uav_ros_simulation:$distro \
uav_ros_simulation:focal-bin-0.0.1 \
/bin/bash

0 comments on commit 02149b9

Please sign in to comment.