Skip to content

Build and Push Image #104

Build and Push Image

Build and Push Image #104

Workflow file for this run

name: Build and Push Image
on:
push:
branches:
- 'main'
- 'refs/tags/releases/v*'
tags:
- 'releases/v**'
workflow_dispatch:
env:
IMAGE_NAME: yacfg_artemis
IMAGE_REGISTRY: quay.io
IMAGE_NAMESPACE: rhmessagingqe
ARCHS: amd64,arm64
jobs:
build:
name: Build and push image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Main Branch Image
if: github.ref == 'refs/heads/main'
id: build-main-branch-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: |
latest
main
${{ github.sha }}
archs: ${{ env.ARCHS }}
containerfiles: |
./Dockerfile
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/releases/v')
id: tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/releases/v}" >> $GITHUB_OUTPUT
- name: Build Release Image
if: startsWith(github.ref, 'refs/tags/releases/v')
id: build-release-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: |
${{ github.sha }}
${{ steps.tag.outputs.TAG_NAME }}
archs: ${{ env.ARCHS }}
containerfiles: |
./Dockerfile
- name: Push Main Image to quay.io
if: github.ref == 'refs/heads/main'
id: push-main-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-main-branch-image.outputs.image }}
tags: ${{ steps.build-main-branch-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Push Release Image to quay.io
if: startsWith(github.ref, 'refs/tags/releases/v')
id: push-release-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-release-image.outputs.image }}
tags: ${{ steps.build-release-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Print image URL
run: echo "Image pushed to ${{ steps.push-main-to-quay.outputs.registry-paths }} ${{ steps.push-release-to-quay.outputs.registry-paths }}"