Fix visual diff comment: drop CDN upload, post artifact link instead
This commit is contained in:
parent
bc39d73c1d
commit
9a6a4bae40
1 changed files with 7 additions and 18 deletions
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
|
@ -153,27 +153,16 @@ jobs:
|
|||
if [ -z "$diffs" ]; then exit 0; fi
|
||||
|
||||
body="## Visual regression failures"$'\n\n'
|
||||
body+="| Test | Diff (reference → actual) |"$'\n'
|
||||
body+="|------|--------------------------|"$'\n'
|
||||
|
||||
body+="The following tests produced screenshot diffs:"$'\n\n'
|
||||
for diff in $diffs; do
|
||||
# Upload image to GitHub's CDN via the issue assets endpoint
|
||||
response=$(curl -sf -X POST \
|
||||
-H "Authorization: Bearer $GH_TOKEN" \
|
||||
-H "Content-Type: image/png" \
|
||||
-H "Accept: application/json" \
|
||||
--data-binary @"$diff" \
|
||||
"https://uploads.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/assets?name=$(basename $diff)")
|
||||
url=$(echo "$response" | jq -r '.url // empty')
|
||||
name=$(basename "$diff" | sed 's/-diff-chromium-linux\.png//' | sed 's/-/ /g')
|
||||
if [ -n "$url" ]; then
|
||||
body+="| \`$name\` |  |"$'\n'
|
||||
else
|
||||
body+="| \`$name\` | *(upload failed)* |"$'\n'
|
||||
fi
|
||||
body+="- \`$name\`"$'\n'
|
||||
done
|
||||
|
||||
body+=$'\n'"Run \`pnpm --filter @trails-cool/planner test:visual:update\` to regenerate snapshots if the change is intentional."
|
||||
body+=$'\n'"**[Download diff screenshots artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** (expand the Visual Tests job → Artifacts)"$'\n\n'
|
||||
body+="To update snapshots if the change is intentional:"$'\n'
|
||||
body+="\`\`\`"$'\n'
|
||||
body+="pnpm --filter @trails-cool/planner test:visual:update"$'\n'
|
||||
body+="\`\`\`"
|
||||
|
||||
gh pr comment ${{ github.event.pull_request.number }} --body "$body"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue