Skip to content

Build and Push Multi-arch Image #12

Build and Push Multi-arch Image

Build and Push Multi-arch Image #12

---
name: Build and Push Multi-arch Image
on: # yamllint disable-line rule:truthy
workflow_run:
workflows:
- validation
branches:
- main
types:
- completed
workflow_dispatch:
env:
IMAGE_TAG: multi-arch
IMAGE_NAME: operator-pipelines-images
IMAGE_REGISTRY: quay.io
IMAGE_NAMESPACE: redhat-isv
jobs:
build-multiarch-images:
name: Build and push multi-architecture image
strategy:
matrix:
architecture: [amd64, ppc64le, s390x, arm64]
platform: [linux]
runs-on: ubuntu-20.04
steps:
- name: add checkout action...
uses: actions/checkout@v4
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ matrix.platform }}-${{ matrix.architecture }}
arch: ${{ matrix.architecture }}
build-args: |
ARCH=${{ matrix.architecture }}
containerfiles: |
./operator-pipeline-images/Dockerfile
- name: Push Image
id: push-image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ matrix.platform }}-${{ matrix.architecture }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
build-multiarch:
needs: build-multiarch-images
runs-on: ubuntu-20.04
steps:
- name: Create and add to manifest
run: |
buildah manifest create ${{ env.IMAGE_NAME }}
buildah manifest add ${{ env.IMAGE_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:linux-amd64
buildah manifest add ${{ env.IMAGE_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:linux-ppc64le
buildah manifest add ${{ env.IMAGE_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:linux-s390x
buildah manifest add ${{ env.IMAGE_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:linux-arm64
# Authenticate to container image registry to push the image
- name: Podman Login
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Push manifest
run: |
podman manifest push ${{ env.IMAGE_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} --all