From a3fad571dcacae1c20582ea64e407da4ac9a039a Mon Sep 17 00:00:00 2001 From: sadath-12 Date: Mon, 8 Jan 2024 22:41:13 +0530 Subject: [PATCH] c Signed-off-by: sadath-12 --- .github/workflows/validate-crd.yaml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/validate-crd.yaml b/.github/workflows/validate-crd.yaml index 89970fe36b0..5a513f706fc 100644 --- a/.github/workflows/validate-crd.yaml +++ b/.github/workflows/validate-crd.yaml @@ -19,18 +19,11 @@ jobs: - name: Check for CRD changes and version update run: | - - - if echo "${{ env.changed_files }}" | grep -q 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/'; then - old_version=$(git show ${{ github.event.pull_request.base.sha }}:pkg/k8s/apis/cilium.io/v1alpha1/register.go | grep 'CustomResourceDefinitionSchemaVersion' | awk -F'"' '{print $2}') - echo "old_version=$old_version" - new_version=$(grep 'CustomResourceDefinitionSchemaVersion' pkg/k8s/apis/cilium.io/v1alpha1/register.go | awk -F'"' '{print $2}') - - if [ -z "$old_version" ]; then - echo "Error: Unable to retrieve old version from the base branch" - exit 1 - - + crd_changed=false + version_changed=false + for changed_file in ${{ steps.changed-files.outputs.all }}; do + if echo "$changed_file" | grep -q 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/'; then + crd_changed=true fi if echo "$changed_file" | grep -q 'pkg/k8s/apis/cilium.io/v1alpha1/register.go'; then @@ -39,17 +32,17 @@ jobs: echo "old_version=$old_version" echo "new_version=$new_version" if [ "$old_version" != "$new_version" ]; then - version_changed=1 + version_changed=true fi fi done - if [ "$crd_changed" -eq 1 ] && [ "$version_changed" -eq 0 ]; then + if [ "$crd_changed" = true ] && [ "$version_changed" = false ]; then echo "CRD changed but version not updated" exit 1 fi - if [ "$crd_changed" -eq 0 ] && [ "$version_changed" -eq 1 ]; then + if [ "$crd_changed" = false ] && [ "$version_changed" = true ]; then echo "Version updated but CRD not changed" exit 1 fi