|
30 | 30 | end |
31 | 31 | end |
32 | 32 |
|
33 | | -# Output as GitHub Actions annotations (since we can't post PR comments without token) |
34 | | -# Using print instead of puts to avoid Danger's "You used puts" warning |
35 | | -if ENV['GITHUB_ACTIONS'] |
36 | | - violation_report[:errors].each do |v| |
37 | | - if v.file && v.line |
38 | | - print "::error file=#{v.file},line=#{v.line}::#{v.message}\n" |
39 | | - else |
40 | | - print "::error::#{v.message}\n" |
41 | | - end |
| 33 | +# Output markdown report for GitHub Actions to post as PR comment |
| 34 | +if ENV['DANGER_REPORT_PATH'] |
| 35 | + report = [] |
| 36 | + report << '## Danger Report' |
| 37 | + report << '' |
| 38 | + |
| 39 | + if violation_report[:errors].any? |
| 40 | + report << '### Errors' |
| 41 | + violation_report[:errors].each { |v| report << "- :no_entry_sign: #{v.message}" } |
| 42 | + report << '' |
42 | 43 | end |
43 | 44 |
|
44 | | - violation_report[:warnings].each do |v| |
45 | | - if v.file && v.line |
46 | | - print "::warning file=#{v.file},line=#{v.line}::#{v.message}\n" |
47 | | - else |
48 | | - print "::warning::#{v.message}\n" |
49 | | - end |
| 45 | + if violation_report[:warnings].any? |
| 46 | + report << '### Warnings' |
| 47 | + violation_report[:warnings].each { |v| report << "- :warning: #{v.message}" } |
| 48 | + report << '' |
50 | 49 | end |
51 | 50 |
|
52 | | - violation_report[:messages].each do |v| |
53 | | - if v.file && v.line |
54 | | - print "::notice file=#{v.file},line=#{v.line}::#{v.message}\n" |
55 | | - else |
56 | | - print "::notice::#{v.message}\n" |
57 | | - end |
| 51 | + if violation_report[:messages].any? |
| 52 | + report << '### Messages' |
| 53 | + violation_report[:messages].each { |v| report << "- :book: #{v.message}" } |
| 54 | + report << '' |
58 | 55 | end |
59 | 56 |
|
60 | | - # Debug: show counts |
61 | | - total = violation_report[:errors].count + violation_report[:warnings].count + violation_report[:messages].count |
62 | | - print "::notice::Danger completed: #{violation_report[:errors].count} errors, #{violation_report[:warnings].count} warnings, #{violation_report[:messages].count} messages\n" |
| 57 | + if violation_report[:errors].empty? && violation_report[:warnings].empty? && violation_report[:messages].empty? |
| 58 | + report << ':white_check_mark: All checks passed!' |
| 59 | + end |
| 60 | + |
| 61 | + File.write(ENV['DANGER_REPORT_PATH'], report.join("\n")) |
63 | 62 | end |
0 commit comments