forked from cilium/tetragon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sadath-12 <[email protected]>
- Loading branch information
Showing
1 changed file
with
24 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |