Skip to content

Commit

Permalink
remove blank space
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Oct 24, 2024
1 parent 0be9fe5 commit 004478a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ jobs:
exit 0
fi
shell: bash
- name: Check for makefile change with blank spaces/tabs
shell: bash
run: |
file_to_check='testfiles/Makefile'
modified_files=$(git diff --name-only && git diff --cached --name-only)
# Remove any duplicate entries from the list of modified files
modified_files=$(echo "$modified_files" | sort | uniq)
# Check if only the specified file is in the list of modified files
if [ "$modified_files" == "$file_to_check" ]; then
echo "Only $file_to_check has been modified"
exit 0
else
echo "Other files have been modified or there are no changes"
exit 1
fi
test-working-dir:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ runs:
echo "Skipping testdata ${file}"
continue
fi
# Extract all image references and their digests
mapfile -t image_lines < <(grep -i -E '[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)*@sha256:[a-z0-9]+' "$file" || true)
for line in "${image_lines[@]}"; do
image=$(echo "$line" | cut -d @ -f1 | rev | cut -d = -f1 | cut -d ' ' -f1 | cut -d '"' -f1 | rev | sed -e "s/^docker:\/\///")
digest=$(echo "$line" | cut -d @ -f2 | cut -d ' ' -f1 | cut -d '"' -f1)
image=$(echo "$line" | cut -d @ -f1 | rev | cut -d = -f1 | cut -d ' ' -f1 | cut -d '"' -f1 | rev | sed -e "s/^docker:\/\///" | tr -d '' | tr -d '\t')
digest=$(echo "$line"| cut -d @ -f2 | cut -d ' ' -f1 | cut -d '"' -f1 | tr -d '' | tr -d '\t')
if [[ "$image" != *":"* ]]; then
echo "Image $image in file $file does not have a tag, ignoring..."
continue
Expand All @@ -88,9 +88,9 @@ runs:
echo "Skipping local registry image $image"
continue
fi
echo "Processing $image in file $file"
updated_digest=
crane digest "$image" > digest.log 2> logerror.txt
if [ $? -eq 0 ]; then
Expand All @@ -103,7 +103,7 @@ runs:
fi
rm -f logerror.txt
rm -f digest.log
if [ "$updated_digest" != "$digest" ] && [ -n "$updated_digest" ]; then
echo "Digest $digest for image $image is different, new digest is $updated_digest, updating..."
sed -i -e "s|$image@$digest|$image@$updated_digest|g" "$file"
Expand Down

0 comments on commit 004478a

Please sign in to comment.