Skip to content

Commit 2ec27fd

Browse files
committed
fix: error condition and summary
1 parent 77fd52c commit 2ec27fd

1 file changed

Lines changed: 36 additions & 10 deletions

File tree

.github/workflows/check-dependency-licenses.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,40 @@ jobs:
4141
- name: Annotate and summarize errors
4242
if: always()
4343
run: |
44-
if grep -q "error found" licensed_status.log || grep -q "errors found" licensed_status.log; then
44+
actual_errors_file=$(mktemp)
45+
46+
awk '
47+
function flush() {
48+
if (block != "") {
49+
print block >> output_file
50+
print "" >> output_file
51+
block = ""
52+
}
53+
}
54+
55+
/^Errors:$/ { in_errors = 1; next }
56+
in_errors && /^\* / { flush(); block = $0; next }
57+
in_errors && /^[[:space:]]+/ {
58+
if (block != "") {
59+
block = block "\n" $0
60+
}
61+
next
62+
}
63+
in_errors && /^$/ { flush(); next }
64+
in_errors { flush(); in_errors = 0 }
65+
END { flush() }
66+
' output_file="$actual_errors_file" licensed_status.log
67+
68+
if [ -s "$actual_errors_file" ]; then
4569
echo "::error::Dependency license cache is out of date. Run 'task license:deps' locally, then review the changes, commit, and push the updated files."
4670
echo "### Licensed Summary" >> $GITHUB_STEP_SUMMARY
47-
echo '| App | Overall Errors (licenses, version updates, ...) |' >> $GITHUB_STEP_SUMMARY
48-
echo '|-----|--------|' >> $GITHUB_STEP_SUMMARY
49-
awk '/Checking cached dependency records for/{app=$6} /error found|errors found/{print "| " app " | " $0 " |"}' licensed_status.log >> $GITHUB_STEP_SUMMARY
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
echo "The following dependency license issues require review:" >> $GITHUB_STEP_SUMMARY
73+
echo "" >> $GITHUB_STEP_SUMMARY
74+
awk '
75+
BEGIN { RS=""; ORS="\n\n" }
76+
NF { print "```text\n" $0 "\n```" }
77+
' "$actual_errors_file" >> $GITHUB_STEP_SUMMARY
5078
5179
5280
# GitHub workflow commands need escaped newlines, otherwise only the
@@ -67,18 +95,16 @@ jobs:
6795
}
6896
}
6997
70-
/^Errors:$/ { in_errors = 1; next }
71-
in_errors && /^\* / { flush(); block = $0; next }
72-
in_errors && /^[[:space:]]+/ {
98+
/^\* / { flush(); block = $0; next }
99+
/^[[:space:]]+/ {
73100
if (block != "") {
74101
block = block "\n" $0
75102
}
76103
next
77104
}
78-
in_errors && /^$/ { flush(); next }
79-
in_errors { flush(); in_errors = 0 }
105+
/^$/ { flush(); next }
80106
END { flush() }
81-
' licensed_status.log
107+
' "$actual_errors_file"
82108
83109
exit 1
84110
else

0 commit comments

Comments
 (0)