Skip to content

fix: Add error handling for config.yaml (#4634) #7161

fix: Add error handling for config.yaml (#4634)

fix: Add error handling for config.yaml (#4634) #7161

name: Busola Web Build
on:
workflow_call:
inputs:
tag:
description: 'Additional tag for built images'
required: true
type: string
push:
branches:
- main
paths:
- '.github/workflows/busola-web-build.yml'
- 'kyma/**'
- 'public/**'
- 'src/**'
- 'package.json'
- 'Makefile'
- 'Dockerfile.web'
- 'nginx/nginx.conf'
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review]
paths:
- '.github/workflows/busola-web-build.yml'
- 'kyma/**'
- 'public/**'
- 'src/**'
- 'package.json'
- 'Makefile'
- 'Dockerfile.web'
- 'nginx/nginx.conf'
permissions:
id-token: write # This is required for requesting the JWT token
contents: read # This is required for actions/checkout
jobs:
build-web-image:
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main
if: github.event.pull_request.draft == false
with:
name: busola-web
dockerfile: Dockerfile.web
tags: ${{ inputs.tag != '' && inputs.tag || 'latest' }}
build-args: ${{ inputs.tag != '' && format('tag={0}', inputs.tag) || '' }}
extract-image-tag:
name: Extract image tag
runs-on: ubuntu-latest
needs: build-web-image
outputs:
image_tag: ${{ steps.extract_tag.outputs.image_tag }}
steps:
- name: Extract tag from built images
id: extract_tag
shell: bash
run: |
images='${{ needs.build-web-image.outputs.images }}'
tag=$(echo "$images" | jq -r '.[]' | grep -v ':latest' | awk -F: '{print $NF}' | head -n1)
echo "image_tag=$tag" >> $GITHUB_OUTPUT
open-pr-for-dev-deploy:
name: Open PR for dev deploy
runs-on: ubuntu-latest
needs: [build-web-image, extract-image-tag]
# open PR only if the image tag starts with 'v20' ensuring only commit tags sent to dev
if: startsWith(needs.extract-image-tag.outputs.image_tag, 'v20')
steps:
- name: Checkout busola-deploy repo
uses: actions/checkout@v4
with:
repository: kyma/busola-deploy
github-server-url: 'https://github.tools.sap'
ref: dev
token: ${{ secrets.BUSOLA_DEPLOY_PAT }}
- name: Update busola_web_image version in dev/main.tf
shell: bash
run: |
sed -i -E 's|(busola_web_image\s*=\s*".*:)[^"]+|\1${{ needs.extract-image-tag.outputs.image_tag }}|' dev/main.tf
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.BUSOLA_DEPLOY_PAT }}
commit-message: 'chore: pr deploy busola-web image to ${{ needs.extract-image-tag.outputs.image_tag }}'
branch: pr-deploy-busola-web-image-${{ needs.extract-image-tag.outputs.image_tag }}
title: 'chore: pr deploy busola-web image to ${{ needs.extract-image-tag.outputs.image_tag }}'
labels: pr-deploy
body: |
This PR updates the Busola web image version in dev/main.tf to ${{ needs.extract-image-tag.outputs.image_tag }}.
base: dev