Skip to content

docker

docker #222

Workflow file for this run

# Builds containers needed for CI, tests and release.
# ci: Contains all dependencies to build the workspace
# ci-testing: Same as CI with ros2-testing packages
# package: Install dependencies needed to build the workspace and generate .deb
# source: Builds the workspace
name: docker
on:
schedule:
# 5 PM UTC every Sunday
- cron: "0 17 * * 6"
workflow_dispatch:
push:
branches:
- humble
pull_request:
paths:
- docker/**
- .github/workflows/docker.yaml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
doc:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
GH_IMAGE: ghcr.io/minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
DH_IMAGE: minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection') }}
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Workaround permission issue # https://github.com/actions/checkout/issues/760#issuecomment-1097501613
run: |
set -x
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Workaround fix permission #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
if: env.PUSH == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ github.job }}/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: ${{ env.PUSH }}
no-cache: true
# TODO also add a tag for project version
tags: |
${{ env.GH_IMAGE }}
${{ env.DH_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
ci:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
GH_IMAGE: ghcr.io/minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
DH_IMAGE: minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection') }}
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Workaround permission issue # https://github.com/actions/checkout/issues/760#issuecomment-1097501613
run: |
set -x
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Workaround fix permission #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
if: env.PUSH == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ github.job }}/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: ${{ env.PUSH }}
no-cache: true
# TODO also add a tag for project version
tags: |
${{ env.GH_IMAGE }}
${{ env.DH_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
ci-testing:
needs: ci
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
GH_IMAGE: ghcr.io/minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
DH_IMAGE: minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection') }}
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Workaround permission issue # https://github.com/actions/checkout/issues/760#issuecomment-1097501613
run: |
set -x
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Workaround fix permission #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3
with:
path: .
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
if: env.PUSH == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ github.job }}/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: ${{ env.PUSH }}
no-cache: true
# TODO also add a tag for project version
tags: |
${{ env.GH_IMAGE }}
${{ env.DH_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
source:
needs: ci-testing
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
GH_IMAGE: ghcr.io/minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
DH_IMAGE: minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection') }}
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Workaround permission issue # https://github.com/actions/checkout/issues/760#issuecomment-1097501613
run: |
set -x
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Workaround fix permission #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3
with:
path: .
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
if: env.PUSH == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Remove .dockerignore
run: rm .dockerignore # enforce full source context
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ github.job }}/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: ${{ env.PUSH }}
no-cache: true
# TODO also add a tag for project version
tags: |
${{ env.GH_IMAGE }}
${{ env.DH_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
source-sim:
needs: source
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
GH_IMAGE: ghcr.io/minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
DH_IMAGE: minipada/ros2_data_collection:${{ matrix.ROS_DISTRO }}-${{ github.job }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection') }}
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Workaround permission issue # https://github.com/actions/checkout/issues/760#issuecomment-1097501613
run: |
set -x
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Workaround fix permission #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3
with:
path: .
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
if: env.PUSH == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Remove .dockerignore
run: rm .dockerignore # enforce full source context
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ github.job }}/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: ${{ env.PUSH }}
no-cache: true
# TODO also add a tag for project version
tags: |
${{ env.GH_IMAGE }}
${{ env.DH_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
delete-untagged:
runs-on: ubuntu-latest
needs:
- source-sim
- doc
steps:
- name: Delete Untagged Images
if: (github.event_name != 'pull_request') && (github.repository == 'minipada/ros2_data_collection')
uses: actions/github-script@v6
with:
github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }}
script: |
const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", {
per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}
env:
OWNER: minipada
PACKAGE_NAME: ros2_data_collection
PER_PAGE: 100