From 589d7afc6ddae0af48b6789731571422db303ce5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 29 May 2023 15:53:43 +0800 Subject: [PATCH] Show added images --- .github/workflows/dvc-diff.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/dvc-diff.yml b/.github/workflows/dvc-diff.yml index 4510185d820..a1f0b1cbfbf 100644 --- a/.github/workflows/dvc-diff.yml +++ b/.github/workflows/dvc-diff.yml @@ -49,9 +49,32 @@ jobs: env: repo_token: ${{ secrets.GITHUB_TOKEN }} run: | + # Summary of changed images echo -e "## Summary of changed images\n" > report.md echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md dvc diff --show-md main HEAD >> report.md + + # Get just the filename of the added and modified image from the report + awk 'NF==5 && NR>=7 && $2=="added" {print $4}' report.md > added_files.txt + awk 'NF==5 && NR>=7 && $2=="modified" {print $4}' report.md > modified_files.txt + + # Append each image to the markdown report + echo -e "## Image diff(s)\n" >> report.md + echo -e "
\n" >> report.md + + # Added images + echo -e "### Added images\n" >> report.md + while IFS= read -r line; do + echo -e "- $line \n" >> report.md + echo -e "![$line]($line)" >> report.md + done < added_files.txt + + echo -e "
\n" >> report.md + + # Mention git commit SHA in the report + echo -e "Report last updated at commit ${{ github.event.pull_request.head.sha }}" >> report.md + + # create/update the PR comment cml comment update report.md - name: Generate the image diff report