mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 15:24:40 +01:00
updates github action check
This commit is contained in:
committed by
Henning Dieterichs
parent
e8f4c461f1
commit
a9c01a08a3
74
.github/workflows/screenshot-test.yml
vendored
74
.github/workflows/screenshot-test.yml
vendored
@@ -11,7 +11,7 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
checks: write
|
||||
|
||||
concurrency:
|
||||
group: screenshots-${{ github.event.pull_request.number || github.sha }}
|
||||
@@ -65,24 +65,28 @@ jobs:
|
||||
test/componentFixtures/.screenshots/report.json
|
||||
test/componentFixtures/.screenshots/report.md
|
||||
|
||||
- name: Set status
|
||||
id: status
|
||||
- name: Set check title
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
REPORT="test/componentFixtures/.screenshots/report.json"
|
||||
if [ -f "$REPORT" ]; then
|
||||
CHANGED=$(node -e "const r = require('./$REPORT'); console.log(r.summary.added + r.summary.removed + r.summary.changed)")
|
||||
STATUS_TEXT="${CHANGED} screenshots changed"
|
||||
TITLE="${CHANGED} screenshots changed"
|
||||
else
|
||||
STATUS_TEXT="Screenshots match"
|
||||
TITLE="Screenshots match"
|
||||
fi
|
||||
|
||||
SHA="${{ github.event.pull_request.head.sha || github.sha }}"
|
||||
gh api "repos/${{ github.repository }}/statuses/$SHA" \
|
||||
-f state=success \
|
||||
-f description="$STATUS_TEXT" \
|
||||
-f context="screenshots"
|
||||
CHECK_RUN_ID=$(gh api "repos/${{ github.repository }}/commits/$SHA/check-runs" \
|
||||
--jq '.check_runs[] | select(.name == "screenshots") | .id')
|
||||
|
||||
if [ -n "$CHECK_RUN_ID" ]; then
|
||||
gh api "repos/${{ github.repository }}/check-runs/$CHECK_RUN_ID" \
|
||||
-X PATCH --input - <<EOF
|
||||
{"output":{"title":"$TITLE","summary":"$TITLE"}}
|
||||
EOF
|
||||
fi
|
||||
|
||||
- name: Post summary
|
||||
run: |
|
||||
@@ -93,29 +97,29 @@ jobs:
|
||||
echo "No visual changes detected." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
- name: Post PR comment
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
COMMENT_MARKER="<!-- screenshot-report -->"
|
||||
BODY="$COMMENT_MARKER"$'\n'
|
||||
|
||||
if [ -f test/componentFixtures/.screenshots/report.md ]; then
|
||||
BODY+=$(cat test/componentFixtures/.screenshots/report.md)
|
||||
BODY+=$'\n\n'
|
||||
BODY+="📦 [Download the \`screenshot-diff\` artifact](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to review images."
|
||||
else
|
||||
BODY+="## Screenshots ✅"$'\n\n'
|
||||
BODY+="No visual changes detected."
|
||||
fi
|
||||
|
||||
# Find existing comment
|
||||
EXISTING=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
|
||||
--paginate --jq ".[] | select(.body | startswith(\"$COMMENT_MARKER\")) | .id" | head -1)
|
||||
|
||||
if [ -n "$EXISTING" ]; then
|
||||
gh api "repos/${{ github.repository }}/issues/comments/$EXISTING" -X PATCH -f body="$BODY"
|
||||
else
|
||||
gh pr comment "${{ github.event.pull_request.number }}" --body "$BODY"
|
||||
fi
|
||||
# - name: Post PR comment
|
||||
# if: github.event_name == 'pull_request'
|
||||
# env:
|
||||
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# run: |
|
||||
# COMMENT_MARKER="<!-- screenshot-report -->"
|
||||
# BODY="$COMMENT_MARKER"$'\n'
|
||||
#
|
||||
# if [ -f test/componentFixtures/.screenshots/report.md ]; then
|
||||
# BODY+=$(cat test/componentFixtures/.screenshots/report.md)
|
||||
# BODY+=$'\n\n'
|
||||
# BODY+="📦 [Download the \`screenshot-diff\` artifact](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to review images."
|
||||
# else
|
||||
# BODY+="## Screenshots ✅"$'\n\n'
|
||||
# BODY+="No visual changes detected."
|
||||
# fi
|
||||
#
|
||||
# # Find existing comment
|
||||
# EXISTING=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
|
||||
# --paginate --jq ".[] | select(.body | startswith(\"$COMMENT_MARKER\")) | .id" | head -1)
|
||||
#
|
||||
# if [ -n "$EXISTING" ]; then
|
||||
# gh api "repos/${{ github.repository }}/issues/comments/$EXISTING" -X PATCH -f body="$BODY"
|
||||
# else
|
||||
# gh pr comment "${{ github.event.pull_request.number }}" --body "$BODY"
|
||||
# fi
|
||||
|
||||
Reference in New Issue
Block a user