Skip to content

Commit

Permalink
ch
Browse files Browse the repository at this point in the history
Signed-off-by: sadath-12 <[email protected]>
  • Loading branch information
sadath-12 committed Dec 27, 2023
1 parent 8319e7d commit 8f64427
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/validate-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand Down

0 comments on commit 8f64427

Please sign in to comment.