Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Github workflows #161

Merged
merged 7 commits into from
Apr 11, 2023
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Build Images

on:
push:
branches: ['*']
tags: ['*']
workflow_call:
inputs:
kuadrantOperatorTag:
description: Kuadrant Operator tag
default: latest
type: string
kuadrantOperatorVersion:
description: Kuadrant Operator version
default: 0.0.0
type: string
authorinoOperatorBundleVersion:
description: Authorino Operator bundle version
default: latest
Expand All @@ -20,6 +25,14 @@ on:
type: string
workflow_dispatch:
inputs:
kuadrantOperatorTag:
description: Kuadrant Operator tag
default: latest
type: string
kuadrantOperatorVersion:
description: Kuadrant Operator version
default: 0.0.0
type: string
authorinoOperatorBundleVersion:
description: Authorino Operator bundle version
default: latest
Expand All @@ -34,7 +47,8 @@ on:
type: string

env:
IMG_TAGS: ${{ github.sha }}
IMG_TAGS: ${{ github.sha }} ${{ inputs.kuadrantOperatorTag }}
VERSION: ${{ inputs.kuadrantOperatorVersion }}
IMG_REGISTRY_HOST: quay.io
IMG_REGISTRY_ORG: kuadrant
MAIN_BRANCH_NAME: main
Expand All @@ -47,24 +61,6 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v2
- 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: Add branch tag
if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }}
id: add-branch-tag
run: |
echo "IMG_TAGS=${GITHUB_REF_NAME/\//-} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Set Operator version
id: operator-version
run: |
if [[ ${GITHUB_REF_NAME/\//-} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "VERSION=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Install qemu dependency
run: |
sudo apt-get update
Expand Down Expand Up @@ -103,49 +99,18 @@ jobs:
id: go
- name: Check out code
uses: actions/checkout@v2
- name: Add latest tag
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-latest-tag
run: |
echo "TAG_NAME=latest" >> $GITHUB_ENV
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Add tag based on branch
if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }}
id: add-branch-tag
run: |
if [[ ${GITHUB_REF_NAME/\//-} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
TAG_NAME=${GITHUB_REF_NAME/\//-}
else
TAG_NAME=${{ github.sha }}
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
echo "IMG_TAGS=${TAG_NAME} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Set Operator version
id: operator-version
run: |
if [[ ${GITHUB_REF_NAME/\//-} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "VERSION=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Run make bundle for workflow dispatch and workflow call
id: workflow-dispatch-call
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }}
- 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=${{ env.TAG_NAME }} \
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.kuadrantOperatorTag }} \
AUTHORINO_OPERATOR_VERSION=${{ inputs.authorinoOperatorBundleVersion }} \
LIMITADOR_OPERATOR_VERSION=${{ inputs.limitadorOperatorBundleVersion }} \
WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }}
- name: Run make bundle for regular events
id: workflow-regular-events
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' }}
run: |
make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} VERSION=${{ env.VERSION }}
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
Expand Down Expand Up @@ -180,13 +145,13 @@ jobs:
id: go
- name: Check out code
uses: actions/checkout@v2
- 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: Generate Catalog Content
run: make catalog
run: |
make catalog REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.kuadrantOperatorTag }} \
AUTHORINO_OPERATOR_VERSION=${{ inputs.authorinoOperatorBundleVersion }} \
LIMITADOR_OPERATOR_VERSION=${{ inputs.limitadorOperatorBundleVersion }} \
WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }}
- name: Install qemu dependency
run: |
sudo apt-get update
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/build-images-branches.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build images for dev branches

on:
push:
branches: ['*']

jobs:
workflow-build:
if: github.ref_name != 'main' && !startsWith(github.ref, 'refs/tags/v')
name: Calls build-images-base workflow
uses: ./.github/workflows/build-images-base.yaml
secrets: inherit
with:
kuadrantOperatorVersion: ${{ github.ref_name }}
kuadrantOperatorTag: ${{ github.ref_name }}
11 changes: 11 additions & 0 deletions .github/workflows/build-images-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build images for main branch

on:
push:
branches: ['main']

jobs:
workflow-build:
name: Calls build-images-base workflow
uses: ./.github/workflows/build-images-base.yaml
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/build-images-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build images for release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
workflow-build:
steps:
- name: Sets release version and tag
run: |
echo REF_NAME=${GITHUB_REF_NAME/\//-}
echo "VERSION=${REF_NAME/v/}" >> $GITHUB_ENV
- name: Calls build-images-base workflow
uses: ./.github/workflows/build-images-base.yaml
secrets: inherit
with:
kuadrantOperatorVersion: ${VERSION}
kuadrantOperatorTag: ${VERSION}
9 changes: 4 additions & 5 deletions .github/workflows/scheduled-build.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: Schedule build with latest image SHA versions

on:
push:
branches: ['main']
schedule:
- cron: '0 0 * * 0'
repository_dispatch: {}

jobs:
workflow-build:
name: Calls build-images workflow
uses: ./.github/workflows/build-images.yaml
name: Calls build-images-base workflow
uses: ./.github/workflows/build-images-base.yaml
secrets: inherit
with:
kuadrantOperatorVersion: ${github.sha}
kuadrantOperatorTag: ${github.sha}
authorinoOperatorBundleVersion: ${vars.AUTHORINO_OPERATOR_BUNDLE_SHA}
limitadorOperatorBundleVersion: ${vars.LIMITADOR_OPERATOR_BUNDLE_SHA}
wasmShimVersion: ${vars.WASM_SHIM_SHA}