Skip to content

Commit 46a71d6

Browse files
Apply template config updates
1 parent a179639 commit 46a71d6

2 files changed

Lines changed: 29 additions & 24 deletions

File tree

.github/workflows/check-images.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,58 @@ jobs:
1616
check-unused-images:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v6
2020

2121
- name: Check for unused images
22+
continue-on-error: true
2223
run: |
2324
unused=()
2425
25-
# Find all images in the root and `images/` directory (if it exists)
26-
images=$(find . -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.svg" -o -iname "*.gif" \) -printf "%P\n")
26+
# Find all images in the root directory
27+
for img in *.png *.jpg *.jpeg *.svg *.gif; do
28+
[ -f "$img" ] && images="$images $img"
29+
done
30+
31+
# Find all images in the images/ directory (if it exists)
2732
if [ -d "./images" ]; then
28-
images+=" $(find ./images -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.svg" -o -iname "*.gif" \) -printf "%P\n")"
33+
for img in ./images/*.png ./images/*.jpg ./images/*.jpeg ./images/*.svg ./images/*.gif; do
34+
[ -f "$img" ] && images="$images $img"
35+
done
36+
fi
37+
38+
# Check if root README.md exists
39+
if [ ! -f "./README.md" ]; then
40+
echo "README.md not found in root directory - skipping image check"
41+
exit 0
2942
fi
3043
31-
# Loop through each image to check if it's referenced in any README files
44+
# Loop through each image to check if it's referenced in the root README.md
3245
for img in $images; do
33-
found=false
34-
while IFS= read -r -d '' readme_file; do
35-
if grep -q "!\[.*\](.*$img.*)" "$readme_file" || grep -q "src=.*$img" "$readme_file"; then
36-
found=true
37-
break
38-
fi
39-
done < <(find . -iname "readme.md" -print0)
46+
# Normalize path: remove leading ./
47+
normalized_img="${img#./}"
4048
41-
if [ "$found" = false ]; then
42-
unused+=("$img")
49+
# Check if the image is referenced in README.md
50+
if ! grep -q "$normalized_img" "./README.md"; then
51+
unused+=("$normalized_img")
4352
fi
4453
done
4554
4655
# Check if there are any unused images
4756
if [ ${#unused[@]} -gt 0 ]; then
48-
echo "Unused images found that are not referenced in any README files:"
57+
echo "Unused images found that are not referenced in the root README.md:"
4958
echo "## Unused Images" >> $GITHUB_STEP_SUMMARY
5059
echo "" >> $GITHUB_STEP_SUMMARY
5160
echo "| Image Name | Path |" >> $GITHUB_STEP_SUMMARY
5261
echo "|------------|------|" >> $GITHUB_STEP_SUMMARY
5362
5463
for img in "${unused[@]}"; do
55-
if [[ -f "./$img" ]]; then
56-
path="./$img"
57-
else
58-
path="./images/$img"
59-
fi
6064
name=$(basename "$img")
61-
echo "$name -> $path"
65+
echo "$name -> $img"
6266
63-
echo "| $name | $path |" >> $GITHUB_STEP_SUMMARY
67+
echo "| $name | $img |" >> $GITHUB_STEP_SUMMARY
6468
done
6569
6670
exit 1
6771
else
68-
echo "No unused images found that are not referenced in README files!"
72+
echo "No unused images found that are not referenced in the root README.md!"
6973
fi

.github/workflows/check-readme.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
uses: actions/checkout@v6
2121

2222
- name: Check links in README
23-
uses: lycheeverse/lychee-action@v1
23+
uses: lycheeverse/lychee-action@v2
24+
continue-on-error: true
2425
with:
2526
args: --verbose --no-progress './**/[Rr][Ee][Aa][Dd][Mm][Ee].md' --exclude-file .lycheeignore
2627
fail: true

0 commit comments

Comments
 (0)