@@ -28,17 +28,18 @@ jobs:
28
28
# | Status | Path |
29
29
# |----------|-------------------------------------|
30
30
# | added | pygmt/tests/baseline/test_image.png |
31
- - name : Get list of images that were added or changed
31
+ - name : Put list of images that were added or changed into report
32
32
run : |
33
33
dvc diff --show-md master HEAD >> report.md
34
34
cat report.md
35
35
36
36
- name : Pull image data from cloud storage
37
37
run : dvc pull --remote upstream
38
38
39
- - name : Report image diff in a GitHub comment
39
+ - name : Put image diff(s) into report
40
40
env :
41
41
repo_token : ${{ secrets.GITHUB_TOKEN }}
42
+ id : image-diff-report
42
43
run : |
43
44
# Get just the filename of the changed image from the report
44
45
tail --lines=+3 report.md | cut --delimiter=' ' --fields=7 > diff_files.txt
50
51
done < diff_files.txt
51
52
52
53
# Send diff report as GitHub comment
53
- cml-send-comment report.md
54
+ # cml-send-comment report.md
55
+
56
+ # Format report to escape newlines before publishing as GitHub comment
57
+ report=$(cat report.md)
58
+ report="${report//'%'/'%25'}"
59
+ report="${report//$'\n'/'%0A'}"
60
+ report="${report//$'\r'/'%0D'}"
61
+ echo ::set-output name=report::$report
62
+
63
+ - name : Find comment with image diff report
64
+ uses :
peter-evans/[email protected]
65
+ id : fc
66
+ with :
67
+ issue-number : ${{ github.event.pull_request.number }}
68
+ comment-author : ' github-actions[bot]'
69
+ body-includes : ' ## Image diff(s)'
70
+
71
+ - name : Create comment with image diff report
72
+ if : steps.fc.outputs.comment-id == ''
73
+ uses :
peter-evans/[email protected]
74
+ with :
75
+ issue-number : ${{ github.event.pull_request.number }}
76
+ body : ${{ steps.get-comment-body.outputs.body }}
77
+
78
+ - name : Update comment with new image diff report
79
+ if : steps.fc.outputs.comment-id != ''
80
+ uses :
peter-evans/[email protected]
81
+ with :
82
+ comment-id : ${{ steps.fc.outputs.comment-id }}
83
+ body : ${{ steps.get-comment-body.outputs.body }}
0 commit comments