Skip to content

Commit 0a0fe27

Browse files
committed
Refactor HTML Empty Line Removal Step
- Replaced Python-based script for removing empty lines from HTML files with a shell-based approach using grep, improving clarity and maintainability. - Added progress messages and a counter for processed files; ensured only non-empty cleaned files replace originals. Signed-off-by: Leonid Petrov <lenia.petrov@gmail.com>
1 parent de80102 commit 0a0fe27

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

.github/workflows/github-actions-s3-publish.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ jobs:
1414
- name: Build
1515
uses: jerryjvl/jekyll-build-action@v1
1616

17-
- name: Remove empty lines from HTML
17+
- name: Remove empty lines from HTML files
1818
run: |
19-
find _site -name "*.html" -type f -exec python3 -c "
20-
import sys
21-
with open(sys.argv[1], 'r') as f:
22-
lines = [line for line in f if line.strip()]
23-
with open(sys.argv[1], 'w') as f:
24-
f.writelines(lines)
25-
" {} \;
26-
19+
echo "Removing empty lines from HTML files..."
20+
count=0
21+
find _site -name "*.html" -type f | while IFS= read -r file; do
22+
# Create temp file with cleaned content
23+
grep -v '^[[:space:]]*$' "$file" > "${file}.cleaned" || true
24+
# Replace original if cleaning succeeded
25+
if [ -s "${file}.cleaned" ]; then
26+
mv "${file}.cleaned" "$file"
27+
((count++)) || true
28+
else
29+
rm -f "${file}.cleaned"
30+
fi
31+
done
32+
echo "✅ Processed HTML files"
2733
2834
- name: Configure AWS credentials
2935
uses: aws-actions/configure-aws-credentials@v1

0 commit comments

Comments
 (0)