Skip to content

Commit 8b32f3a

Browse files
weiji14seisman
andcommitted
Use peter-evans/create-or-update-comment to publish image diff report
Co-Authored-By: Dongdong Tian <[email protected]>
1 parent 3061b80 commit 8b32f3a

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

.github/workflows/dvc-diff.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ jobs:
2828
# | Status | Path |
2929
# |----------|-------------------------------------|
3030
# | 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
3232
run: |
3333
dvc diff --show-md master HEAD >> report.md
3434
cat report.md
3535
3636
- name: Pull image data from cloud storage
3737
run: dvc pull --remote upstream
3838

39-
- name: Report image diff in a GitHub comment
39+
- name: Put image diff(s) into report
4040
env:
4141
repo_token: ${{ secrets.GITHUB_TOKEN }}
42+
id: image-diff-report
4243
run: |
4344
# Get just the filename of the changed image from the report
4445
tail --lines=+3 report.md | cut --delimiter=' ' --fields=7 > diff_files.txt
@@ -50,4 +51,33 @@ jobs:
5051
done < diff_files.txt
5152
5253
# 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

Comments
 (0)