From 8f64427e5de7312b7565b7890f25d65f23e0d35a Mon Sep 17 00:00:00 2001 From: sadath-12 Date: Thu, 28 Dec 2023 01:33:45 +0530 Subject: [PATCH] ch Signed-off-by: sadath-12 --- .github/workflows/validate-crd.yaml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/validate-crd.yaml b/.github/workflows/validate-crd.yaml index 5a33b34dc99..a24ae306dde 100644 --- a/.github/workflows/validate-crd.yaml +++ b/.github/workflows/validate-crd.yaml @@ -3,21 +3,26 @@ on: pull_request: paths: - 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/*.yaml' - jobs: check-version: runs-on: ubuntu-22.04 steps: - - name: Checkout repository - uses: actions/checkout@v2 - + - name: Checkout code + uses: actions/checkout@v2 # you need this step to access the repository files + - id: file_changes # use the File Changes Action + uses: trilom/file-changes-action@v1.2.4 + with: + output: ' ' # use space as the delimiter for output variables - name: Check for CRD changes and version update run: | - changed_files=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }}) + # use the modified files from the output variable + if git diff --name-only $ { { steps.file_changes.outputs.files_modified }} | grep -q 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/'; then + old_version=$(grep 'CustomResourceDefinitionSchemaVersion' pkg/k8s/apis/cilium.io/v1alpha1/register.go | awk -F'"' '{print $2}') + + new_version=$(grep 'CustomResourceDefinitionSchemaVersion' pkg/k8s/apis/cilium.io/v1alpha1/register.go | awk -F'"' '{print $2}') - if echo "$changed_files" | grep -q 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/'; then - if ! echo "$changed_files" | grep -q 'pkg/k8s/apis/cilium.io/v1alpha1/register.go'; then - echo "Error: CRD files changed, but register.go not modified." + if [ "$old_version" == "$new_version" ]; then + echo "Error: CRD version not updated! Please update the CustomResourceDefinitionSchemaVersion in register.go" exit 1 fi else