Skip to content

Commit 3078399

Browse files
committed
Improve HTML Cleaning Step in github-actions-s3-publish.yml
- Replaced the previous method for removing empty lines from HTML files with a more robust script that also compresses consecutive empty lines and trims whitespace. - The new approach uses a combination of awk and sed for more thorough cleaning, ensuring only a single empty line is retained and all extraneous whitespace is removed. Signed-off-by: Leonid Petrov <lenia.petrov@gmail.com>
1 parent 0a0fe27 commit 3078399

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

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

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

17-
- name: Remove empty lines from HTML files
18-
run: |
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
17+
- name: Clean HTML files properly
18+
run: |
19+
find _site -name "*.html" -type f -exec sh -c '
20+
for file; do
21+
# Remove empty lines, whitespace lines, and compress newlines
22+
awk "NF || !p; {p=NF}" "$file" | \
23+
sed "s/^[[:space:]]*$//" | \
24+
awk "!NF{if (++n<=1) print; next}; {n=0; print}" > "$file.tmp" && \
25+
mv "$file.tmp" "$file"
3126
done
32-
echo "✅ Processed HTML files"
27+
' sh {} +
28+
29+
3330
3431
- name: Configure AWS credentials
3532
uses: aws-actions/configure-aws-credentials@v1

0 commit comments

Comments
 (0)