Build Images #15
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 Images | |
on: | |
workflow_call: | |
inputs: | |
operatorVersion: | |
description: Operator bundle version | |
default: 0.0.0 | |
type: string | |
operatorTag: | |
description: Operator tag | |
default: latest | |
type: string | |
limitadorVersion: | |
description: Limitador version | |
default: latest | |
type: string | |
channels: | |
description: Bundle and catalog channels, comma separated | |
default: preview | |
type: string | |
defaultChannel: | |
description: Bundle default channel | |
default: preview | |
type: string | |
quayImageExpiry: | |
description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built. | |
default: never | |
type: string | |
workflow_dispatch: | |
inputs: | |
operatorVersion: | |
description: Operator bundle version | |
default: 0.0.0 | |
type: string | |
operatorTag: | |
description: Operator tag | |
default: latest | |
type: string | |
limitadorVersion: | |
description: Limitador version | |
default: latest | |
type: string | |
channels: | |
description: Bundle and catalog channels, comma separated | |
default: preview | |
type: string | |
defaultChannel: | |
description: Bundle default channel | |
default: preview | |
type: string | |
quayImageExpiry: | |
description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built. | |
default: never | |
type: string | |
env: | |
IMG_TAGS: ${{ inputs.operatorTag }} | |
VERSION: ${{ inputs.operatorVersion }} | |
IMG_REGISTRY_HOST: quay.io | |
IMG_REGISTRY_ORG: kuadrant | |
MAIN_BRANCH_NAME: main | |
OPERATOR_NAME: limitador-operator | |
QUAY_IMAGE_EXPIRY: ${{ inputs.quayImageExpiry }} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install qemu dependency | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-user-static | |
- name: Add git sha tag for the main branch | |
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | |
id: add-git-sha-tag | |
run: | | |
echo "IMG_TAGS=${{ github.sha }} ${{ 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 }} | |
platforms: linux/amd64,linux/arm64 | |
dockerfiles: | | |
./Dockerfile | |
build-args: | | |
GIT_SHA=${{ github.sha }} | |
DIRTY=false | |
QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }} | |
- name: Push Image | |
if: ${{ !env.ACT }} | |
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: | |
needs: build | |
name: Build Bundle | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.21.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21.x | |
id: go | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install qemu dependency | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-user-static | |
- name: Run make bundle | |
id: make-bundle | |
run: | | |
make bundle \ | |
REGISTRY=${{ env.IMG_REGISTRY_HOST }} \ | |
ORG=${{ env.IMG_REGISTRY_ORG }} \ | |
VERSION=${{ env.VERSION }} \ | |
IMAGE_TAG=${{ inputs.operatorTag }} \ | |
LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \ | |
DEFAULT_CHANNEL=${{ inputs.defaultChannel }} \ | |
CHANNELS=${{ inputs.channels }} | |
- name: Add git sha tag for the main branch | |
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | |
id: add-git-sha-tag | |
run: | | |
echo "IMG_TAGS=${{ github.sha }} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV | |
- name: Build Image | |
id: build-image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
image: ${{ env.OPERATOR_NAME }}-bundle | |
tags: ${{ env.IMG_TAGS }} | |
platforms: linux/amd64,linux/arm64 | |
dockerfiles: | | |
./bundle.Dockerfile | |
build-args: | | |
QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }} | |
- name: Push Image | |
if: ${{ !env.ACT }} | |
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 Catalog | |
needs: [build, build-bundle] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.21.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21.x | |
id: go | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Generate Catalog Content | |
run: | | |
make catalog \ | |
REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ | |
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.operatorTag }} \ | |
LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \ | |
DEFAULT_CHANNEL=${{ inputs.defaultChannel }} | |
- name: Install qemu dependency | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-user-static | |
- name: Add git sha tag for the main branch | |
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | |
id: add-git-sha-tag | |
run: | | |
echo "IMG_TAGS=${{ github.sha }} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV | |
- name: Build Image | |
id: build-image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
image: ${{ env.OPERATOR_NAME }}-catalog | |
tags: ${{ env.IMG_TAGS }} | |
platforms: linux/amd64,linux/arm64 | |
context: ./catalog | |
dockerfiles: | | |
./catalog/${{ env.OPERATOR_NAME }}-catalog.Dockerfile | |
# The Quay image expiry label for the generated catalog Dockerfile is set via opm, using the value set in the QUAY_IMAGE_EXPIRY environment variable | |
- name: Push Image | |
if: ${{ !env.ACT }} | |
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 }}" |