@@ -32,33 +32,51 @@ jobs:
32
32
# | Status | Path |
33
33
# |----------|-------------------------------------|
34
34
# | added | pygmt/tests/baseline/test_image.png |
35
- - name : Put list of images that were added or changed into report
35
+ # | deleted | pygmt/tests/baseline/test_image2.png |
36
+ # | modified | pygmt/tests/baseline/test_image3.png |
37
+ - name : Generate the image diff report
38
+ env :
39
+ repo_token : ${{ secrets.GITHUB_TOKEN }}
40
+ id : image-diff
36
41
run : |
37
42
echo -e "## Summary of changed images\n" > report.md
38
43
echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md
39
44
dvc diff --show-md master HEAD >> report.md
40
- cat report.md
41
-
42
- - name : Pull image data from cloud storage
43
- run : dvc pull --remote upstream
44
45
45
- - name : Put image diff(s) into report
46
- env :
47
- repo_token : ${{ secrets.GITHUB_TOKEN }}
48
- id : image-diff
49
- run : |
50
- # Get just the filename of the changed image from the report
51
- awk 'NF==5 && NR>=7 {print $4}' report.md > diff_files.txt
46
+ # Get just the filename of the added and modified image from the report
47
+ awk 'NF==5 && NR>=7 && $2=="added" {print $4}' report.md > added_files.txt
48
+ awk 'NF==5 && NR>=7 && $2=="modified" {print $4}' report.md > modified_files.txt
52
49
53
50
# Append each image to the markdown report
54
51
echo -e "## Image diff(s)\n" >> report.md
55
52
echo -e "<details>\n" >> report.md
56
53
54
+ # Modified images
55
+ echo -e "### Modified images\n" >> report.md
56
+ # Upload old images
57
+ while IFS= read -r line; do
58
+ cml-publish --title $line --md "$line" > modified_images_old.md < /dev/null
59
+ done < modified_files.txt
60
+
61
+ # Pull image data from cloud storage
62
+ dvc pull --remote upstream
63
+
64
+ # Upload new images
65
+ while IFS= read -r line; do
66
+ cml-publish --title $line --md "$line" > modified_images_new.md < /dev/null
67
+ done < modified_files.txt
68
+
69
+ # Append image report for modified images
70
+ echo -e "| Path | Old | New |" >> report.md
71
+ echo -e "|---|---|---|" >> report.md
72
+ paste modified_files.txt modified_images_old.md modified_images_new.md -d"|" | awk '{print "|", $0, "|"}' >> report.md
73
+
74
+ # Added images
75
+ echo -e "### Added images\n" >> report.md
57
76
while IFS= read -r line; do
58
77
echo -e "- $line \n" >> report.md
59
78
cml-publish --title $line --md "$line" >> report.md < /dev/null
60
- done < diff_files.txt
61
-
79
+ done < adde_files.txt
62
80
echo -e "</details>\n" >> report.md
63
81
64
82
# Mention git commit SHA in the report
0 commit comments