Skip to content

Commit dc07c5a

Browse files
committed
Output a summary and not an annotation
An original implementation of this used annotations, rather job summaries but these don't really work that well. We can't comment on files which have changed outside of the diff, so the output is mostly shown in the log output or the autogenerated job summary. Instead, we assemble a custom output which is much nicer. https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/ https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
1 parent 4f99a35 commit dc07c5a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

bin/diff-check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
set -e
44

5-
message="has changed"
6-
75
if ! git diff-index --quiet HEAD; then
6+
printf 'These files changed when running the command:\n\n'
7+
88
git diff --name-only | while read -r n ; do
9-
echo "::error file=$n::$n $message"
9+
echo "* $n"
1010
done
1111

1212
exit 1

spec/black_box/diff-check_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
end
1818

1919
context "with a file change" do
20-
it "emits a annotation with the file" do
20+
it "emits a summary with the files changed" do
2121
session = create_session
2222

2323
session.run("echo 'new text' >> README")
2424

25-
expect(session.run("diff-check")).
26-
to have_stdout("::error file=README::README has changed\n")
25+
expect(session.run("diff-check")).to have_stdout(<<~SUMMARY
26+
These files changed when running the command:
27+
28+
* README
29+
SUMMARY
30+
)
2731
end
2832

2933
it "exits with a status of 1" do

0 commit comments

Comments
 (0)