Skip to content

Merge pull request #494 from Kuadrant/allow-istio-operator-name #145

Merge pull request #494 from Kuadrant/allow-istio-operator-name

Merge pull request #494 from Kuadrant/allow-istio-operator-name #145

name: Build and Publish Controller Image
on:
push:
branches:
- main
- "release-*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
IMG_REGISTRY_HOST: quay.io
IMG_REGISTRY_ORG: kuadrant
IMG_REGISTRY_REPO: multicluster-gateway-controller
MAIN_BRANCH_NAME: main
jobs:
build:
if: github.repository_owner == 'kuadrant'
name: Build and Publish Controller Image
runs-on: ubuntu-22.04
outputs:
sha_short: ${{ steps.vars.outputs.sha_short }}
controller_image: ${{ steps.vars.outputs.base_image }}:${{ steps.vars.outputs.sha_short }}
steps:
- uses: actions/checkout@v3
- name: Calculate vars
id: vars
run: |
echo "sha_short=$(echo ${{ github.sha }} | cut -b -7)" >> $GITHUB_OUTPUT
echo "base_image=${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.IMG_REGISTRY_REPO }}" >> $GITHUB_OUTPUT
- name: Add image tags
id: add-tags
run: echo "IMG_TAGS=${{ steps.vars.outputs.base_image }}:${{ steps.vars.outputs.sha_short }},${{ steps.vars.outputs.base_image }}:${{ github.ref_name }}" >> $GITHUB_ENV
- name: Add latest tag
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-latest-tag
run: echo "IMG_TAGS=${{ steps.vars.outputs.base_image }}:latest,${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Login to Quay.io
uses: docker/login-action@v2
id: registry-login
with:
registry: ${{ env.IMG_REGISTRY_HOST }}
username: ${{ secrets.IMG_REGISTRY_USERNAME }}
password: ${{ secrets.IMG_REGISTRY_TOKEN }}
- name: Build and push Controller Image
id: build-and-push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.IMG_TAGS }}
target: controller
- name: Print Image URL
run: |
echo "Image pushed to ${{ env.IMG_TAGS }}"
echo "Image digest: ${{ steps.build-and-push.outputs.digest }}"
update-hcg-unstable:
if: "github.repository_owner == 'kuadrant' && github.ref_name == 'main'"
name: Update HCG unstable
runs-on: ubuntu-22.04
needs: build
steps:
- uses: actions/checkout@v3
with:
repository: Kuadrant/deployments
ref: 'main'
ssh-key: ${{ secrets.KUADRANT_DEPLOYMENTS_SSH_DEPLOY_KEY }}
- name: Install kustomize
run: make kustomize
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<[email protected]>"
- name: Update controller image
run: |
export KUSTOMIZE=$(pwd)/bin/kustomize
cd hcg/mctc/environments/unstable
${KUSTOMIZE} edit set image controller=${{ needs.build.outputs.controller_image }}
- name: Commit the change for ArgoCD to pick it up
run: |
git add hcg/mctc/environments/unstable/kustomization.yaml
git commit -m "Update controller image to ${{ needs.build.outputs.controller_image }}"
git push origin main