Skip to content

Commit

Permalink
XS✔ ◾ 📷 Updated CheckExtensionCase workflow for image extensions (#9215)
Browse files Browse the repository at this point in the history
* added test workflow for checking image extensions

* changed branch

* changed name

* added test image

* testing GIF

* added checks for png and jpg case

* added test workflow

* test JPEG

* refactor style

* refactor to handle 4 length extension

* test JPG

* refactor

* refactor to make it work for JPG

* added logs

* changed the fileExtension

* added check for "

* added more logs

* test JPEG

* test WEBP

* added check for jpeg and webp
  • Loading branch information
babakamyljanovssw authored Sep 20, 2024
1 parent 91d6081 commit 467db6c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/check-extension-case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- id: file_changes
uses: trilom/[email protected]

- name: test
- name: check-image-extension-case
run: |
FILES=${{steps.file_changes.outputs.files_added}}
Expand All @@ -24,13 +24,26 @@ jobs:
for filename in "${myarray[@]}"
do
fileExtension=$(echo $filename | sed 's/"//g' | sed 's/]//g' | grep -o '...$')
echo "Checking file: $filename"
# Extract the extension (everything after the last dot)
fileExtension="${filename##*.}"
# Remove unwanted characters from the extension (specifically ] and ")
fileExtension=$(echo "$fileExtension" | tr -d '"]')
lowercaseFileExtension=$(echo "$fileExtension" | tr '[:upper:]' '[:lower:]')
if [ $lowercaseFileExtension == 'gif' ] || [ $lowercaseFileExtension == 'svg' ]
if [ $lowercaseFileExtension == 'gif' ] || \
[ $lowercaseFileExtension == 'svg' ] || \
[ $lowercaseFileExtension == 'png' ] || \
[ $lowercaseFileExtension == 'jpg' ] || \
[ $lowercaseFileExtension == 'jpeg' ] || \
[ $lowercaseFileExtension == 'webp' ]
then
if ! [[ $fileExtension =~ ^[[:lower:]]+$ ]];
if [ "$fileExtension" != "$lowercaseFileExtension" ];
then
echo "Use lowercase file extensions"
echo "Error: Use lowercase file extensions"
exit 1
fi
fi
Expand Down

0 comments on commit 467db6c

Please sign in to comment.