diff --git a/.github/workflows/validate-crd.yaml b/.github/workflows/validate-crd.yaml index bed21de0df5..89970fe36b0 100644 --- a/.github/workflows/validate-crd.yaml +++ b/.github/workflows/validate-crd.yaml @@ -20,6 +20,7 @@ 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" @@ -29,6 +30,7 @@ jobs: echo "Error: Unable to retrieve old version from the base branch" exit 1 + fi if echo "$changed_file" | grep -q 'pkg/k8s/apis/cilium.io/v1alpha1/register.go'; then @@ -37,20 +39,20 @@ jobs: echo "old_version=$old_version" echo "new_version=$new_version" if [ "$old_version" != "$new_version" ]; then - version_changed=true + version_changed=1 fi fi done - if [ "$crd_changed" = true ] && [ "$version_changed" = false ]; then + if [ "$crd_changed" -eq 1 ] && [ "$version_changed" -eq 0 ]; then echo "CRD changed but version not updated" exit 1 fi - if [ "$crd_changed" = false ] && [ "$version_changed" = true ]; then + if [ "$crd_changed" -eq 0 ] && [ "$version_changed" -eq 1 ]; then echo "Version updated but CRD not changed" exit 1 fi - echo crd_changed=$crd_changed - echo version_changed=$version_changed + echo "crd_changed=$crd_changed" + echo "version_changed=$version_changed"