Build and Push Multi-Arch Image with Buildah #119
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Multi-Arch Image | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
env: | |
REGISTRY_USER: ${{ secrets.QUAY_USER }} | |
REGISTRY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} | |
IMAGE_NAME: quay.io/kuadrant/console-plugin | |
jobs: | |
build: | |
name: Build and Push Multi-Arch Image | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Remove Buildx Builder | |
run: docker buildx rm builder || true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Quay.io | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
registry: quay.io | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Build and Push Multi-Arch Image (Main) | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.IMAGE_NAME }}:latest | |
${{ env.IMAGE_NAME }}:${{ github.sha }} | |
- name: Build and Push Versioned Multi-Arch Image (Release) | |
if: github.event_name == 'release' && github.event.action == 'published' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ github.event.release.name }} | |
- name: Print main branch image URL | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: echo "Main branch image pushed to ${{ env.IMAGE_NAME }}:latest and ${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
- name: Print versioned image URL | |
if: github.event_name == 'release' && github.event.action == 'published' | |
run: echo "Versioned image pushed to ${{ env.IMAGE_NAME }}:${{ github.event.release.name }}" |