-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use peter-evans/create-or-update-comment to publish image diff report
Co-Authored-By: Dongdong Tian <[email protected]>
- Loading branch information
Showing
1 changed file
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
run: | | ||
# Get just the filename of the changed image from the report | ||
tail --lines=+3 report.md | cut --delimiter=' ' --fields=7 > diff_files.txt | ||
|
@@ -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.image-diff.outputs.report }} | ||
|
||
- 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.image-diff.outputs.report }} |