Skip to content

Update docker-publish.yml #10

Update docker-publish.yml

Update docker-publish.yml #10

name: Publish Docker image to ghcr
on:
push:
branches: [ main ]
workflow_dispatch:
pull_request:
types: [opened, reopened]
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
architecture:
- amd64
- arm64
filename:
- arm64-ros2
- arm64-ros2-CUDA
permissions:
contents: read
packages: write
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.architecture != 'amd64'
uses: docker/setup-qemu-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.filename }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.${{ matrix.filename }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ matrix.filename }}:${{ matrix.architecture }}-latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64