Skip to content

Commit

Permalink
Use peter-evans/create-or-update-comment to publish image diff report
Browse files Browse the repository at this point in the history
Co-Authored-By: Dongdong Tian <[email protected]>
  • Loading branch information
weiji14 and seisman committed Mar 25, 2021
1 parent 3061b80 commit 8b32f3a
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/dvc-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ jobs:
# | Status | Path |
# |----------|-------------------------------------|
# | added | pygmt/tests/baseline/test_image.png |
- name: Get list of images that were added or changed
- name: Put list of images that were added or changed into report
run: |
dvc diff --show-md master HEAD >> report.md
cat report.md
- name: Pull image data from cloud storage
run: dvc pull --remote upstream

- name: Report image diff in a GitHub comment
- name: Put image diff(s) into report
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
id: image-diff-report
run: |
# Get just the filename of the changed image from the report
tail --lines=+3 report.md | cut --delimiter=' ' --fields=7 > diff_files.txt
Expand All @@ -50,4 +51,33 @@ jobs:
done < diff_files.txt
# Send diff report as GitHub comment
cml-send-comment report.md
# cml-send-comment report.md
# Format report to escape newlines before publishing as GitHub comment
report=$(cat report.md)
report="${report//'%'/'%25'}"
report="${report//$'\n'/'%0A'}"
report="${report//$'\r'/'%0D'}"
echo ::set-output name=report::$report
- name: Find comment with image diff report
uses: peter-evans/[email protected]
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '## Image diff(s)'

- name: Create comment with image diff report
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update comment with new image diff report
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: ${{ steps.get-comment-body.outputs.body }}

0 comments on commit 8b32f3a

Please sign in to comment.