Skip to content

Commit

Permalink
s
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 8f64427 commit 1629fa3
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions .github/workflows/validate-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ jobs:
steps:
- 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: Get changed files
id: get_changed_files
shell: pwsh # use PowerShell as the shell
run: |
# get the SHA of the base and head commits
$base = $env:GITHUB_BASE_REF
$head = $env:GITHUB_HEAD_REF
# get the list of changed files
$files = git diff --name-only $base $head
# filter the list by a regex pattern
$pattern = 'pkg/k8s/apis/cilium.io/client/crds/v1alpha1/'
$filtered = $files -match $pattern
# set the output variable
if ($filtered) {
echo "::set-output name=crd_changed::true"
} else {
echo "::set-output name=crd_changed::false"
}
- name: Check for CRD changes and version update
if: steps.get_changed_files.outputs.crd_changed == 'true' # use the output variable as a condition
run: |
# 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}')
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}')
new_version=$(grep 'CustomResourceDefinitionSchemaVersion' pkg/k8s/apis/cilium.io/v1alpha1/register.go | awk -F'"' '{print $2}')
if [ "$old_version" == "$new_version" ]; then
echo "Error: CRD version not updated! Please update the CustomResourceDefinitionSchemaVersion in register.go"
exit 1
fi
else
echo "No changes in the CRD files"
if [ "$old_version" == "$new_version" ]; then
echo "Error: CRD version not updated! Please update the CustomResourceDefinitionSchemaVersion in register.go"
exit 1
fi

0 comments on commit 1629fa3

Please sign in to comment.