Skip to content

Docker Image CI

Docker Image CI #9

Workflow file for this run

name: Docker Image CI
on:
push:
branches:
- main
paths:
- Dockerfile
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
#For architecture emulation
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
#For multi-architecture image building
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build the specific stage of the multi-stage Dockerfile
- uses: actions/checkout@v3
- name: Set Docker repository name
id: set_docker_repo_name
run: echo "{docker_repo_name}=$(echo ${GITHUB_REPOSITORY#*/} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:latest -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:$(date +"%Y%m%d%H%M%S") .devcontainer/ros2/.
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:$(date +"%Y%m%d%H%M%S")