Skip to content

Commit b9f6a4e

Browse files
committed
Group messages into headers with files as details.
1 parent b747a6f commit b9f6a4e

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,47 @@ jobs:
131131
printf "All images are optimized without problems.\n" >> "$GITHUB_STEP_SUMMARY"
132132
else
133133
if [ -n "$warnings" ]; then
134-
echo "$warnings" | sed -E 's/^##\[warning\](.*)/\n> [!WARNING]\n> \1\n/' >> "$GITHUB_STEP_SUMMARY"
134+
echo "$warnings" | awk '
135+
match($0, /^##\[warning\]Skipped `([^`]+)` because `([^`]+)`/, arr) {
136+
file = arr[1]
137+
msg = arr[2]
138+
count[msg]++
139+
files[msg] = (files[msg] == "" ? "" : files[msg] "\n") "- `" file "`"
140+
}
141+
END {
142+
for (msg in count) {
143+
print "\n> [!WARNING]"
144+
print "> " count[msg] "x Skipped because " msg "\n"
145+
print "<details><summary>Show files</summary>\n"
146+
print files[msg]
147+
print "\n</details>"
148+
}
149+
}' >> "$GITHUB_STEP_SUMMARY"
135150
fi
136151
137152
if [ -n "$notices" ]; then
138-
{
139-
printf '> [!NOTE]\n> Some files had warnings\n'
140-
printf '<details><summary>Details</summary><pre>\n'
141-
echo "$notices" | sed -E 's/^##\[notice\](.*)/- \1/'
142-
echo '</pre></details>'
143-
} >> "$GITHUB_STEP_SUMMARY"
153+
echo "$notices" | awk '
154+
match($0, /^##\[notice\]Optimized `([^`]+)` despite `([^`]+)`/, arr) {
155+
file = arr[1]
156+
msg = arr[2]
157+
count[msg]++
158+
files[msg] = (files[msg] == "" ? "" : files[msg] "\n") "- `" file "`"
159+
}
160+
END {
161+
for (msg in count) {
162+
print "\n> [!NOTE]"
163+
print "> Files optimized despite " count[msg] "x " msg "\n"
164+
print "<details><summary>Show files</summary>\n"
165+
print files[msg]
166+
print "\n</details>"
167+
}
168+
}' >> "$GITHUB_STEP_SUMMARY"
144169
fi
145170
fi
146171
172+
# Need some single quote to workaround a VS colorizer bug
173+
echo 'Done.'
174+
147175
- name: Summarize artifacts
148176
run: |
149177
echo '# Artifacts' >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)