Skip to content

Add build-images workflow #6

Add build-images workflow

Add build-images workflow #6

Workflow file for this run

name: Build and Publish Images
on:
push:
branches:
- main
- "release-*"
- "gh-actions-*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
tag:
description: Tag
required: false
default: latest
env:
IMG_TAGS: ${{ github.sha }} ${{ github.ref_name }}
IMG_REGISTRY_HOST: quay.io
IMG_REGISTRY_ORG: kuadrant
IMG_REGISTRY_REPO: kuadrant-dns-operator
MAIN_BRANCH_NAME: main
OPERATOR_NAME: kuadrant-dns-operator
jobs:
build:
name: Build and Push image
runs-on: ubuntu-20.04
outputs:
build-image: ${{ steps.build-image.outputs.image }}
build-tags: ${{ steps.build-image.outputs.tags }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Add latest tag
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-latest-tag
run: |
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.OPERATOR_NAME }}
tags: ${{ env.IMG_TAGS }}
dockerfiles: |
./Dockerfile
- name: Print Build Info
run: echo "Image = ${{ steps.build-image.outputs.image }}, Tags = ${{ steps.build-image.outputs.tags }}"
- name: Push Image
if: github.repository_owner == 'kuadrant'
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}
username: ${{ secrets.IMG_REGISTRY_USERNAME }}
password: ${{ secrets.IMG_REGISTRY_TOKEN }}
- name: Print Image URL
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
build-bundle:
name: Build and Push bundle image
needs: [build]
runs-on: ubuntu-20.04
outputs:
bundle-image: ${{ steps.build-image.outputs.image }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run make bundle
run: make bundle IMG=${{ needs.build.outputs.build-image }}:${{ github.sha }}
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.OPERATOR_NAME }}-bundle
tags: ${{ needs.build.outputs.build-tags }}
dockerfiles: |
./bundle.Dockerfile
- name: Print Build Info
run: echo "Image = ${{ steps.build-image.outputs.image }}, Tags = ${{ steps.build-image.outputs.tags }}"
- name: Push Image
if: github.repository_owner == 'kuadrant'
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}
username: ${{ secrets.IMG_REGISTRY_USERNAME }}
password: ${{ secrets.IMG_REGISTRY_TOKEN }}
- name: Print Image URL
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
build-catalog:
name: Build and Push catalog image
needs: [build-bundle]
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run make catalog-build
run: make bundle BUNDLE_IMG=${{ needs.build-bundle.outputs.bundle-image }}:${{ github.sha }}