Skip to content

tags for semantic versioning only #264

tags for semantic versioning only

tags for semantic versioning only #264

Workflow file for this run

name: Build Docker Images
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
schedule:
- cron: '30 4 * * 0,2,4,6'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.tag }} base image (${{ github.event_name }} by ${{ github.actor }})
runs-on: ubuntu-latest
strategy:
matrix:
tag:
# - noetic
- humble
- iron
- rolling
steps:
- uses: actions/checkout@v3
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Docker Login LCAS
# You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
# Server address of Docker registry. If not set then will default to Docker Hub
registry: lcas.lincoln.ac.uk
# Username used to log against the Docker registry
username: ${{ secrets.LCAS_REGISTRY_PUSHER }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.LCAS_REGISTRY_TOKEN }}
- name: Docker Login dockerhub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
# Username used to log against the Docker registry
username: ${{ secrets.DOCKERHUB_USER }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "image name from repo name"
id: docker_image_name
run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
labels: |
org.opencontainers.image.description=L-CAS ROS2 Docker Image (flavour: ${{ matrix.tag }}, multiarch)
org.opencontainers.image.authors=L-CAS Team
# list of Docker images to use as base name for tags
images: |
lcas.lincoln.ac.uk/${{ steps.docker_image_name.outputs.docker_image }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ matrix.tag }}-staging
type=raw,enable=${{ github.event_name != 'pull_request' }},value=${{ matrix.tag }}
type=ref,enable=${{ github.event_name != 'pull_request' }},event=branch,prefix=${{ matrix.tag }}-
type=semver,pattern={{version}},prefix=${{ matrix.tag }}-
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.tag }}-
type=semver,pattern={{major}},prefix=${{ matrix.tag }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.tag }}
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.tag }},mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=ros:${{ matrix.tag }}
BRANCH=${{ env.BRANCH }}