mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
ci: Adjust to duplicate write status (#49005)
* chore: diff for it * chore: status
This commit is contained in:
parent
4b44c737b9
commit
9b916f6f32
@ -59,6 +59,7 @@ jobs:
|
||||
actions: read # for dawidd6/action-download-artifact to query and download artifacts
|
||||
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
|
||||
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
|
||||
statuses: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: [upstream-workflow-summary]
|
||||
steps:
|
||||
@ -141,29 +142,31 @@ jobs:
|
||||
body-include: '<!-- VISUAL_DIFF_REGRESSION_HOOK -->'
|
||||
number: ${{ steps.pr.outputs.id }}
|
||||
|
||||
# Update PR description with updated time: `snapshot:[TIMESTAMP]`
|
||||
- name: Update timestamp
|
||||
if: ${{ always() }}
|
||||
# Resync commit status. This will be also reset by `visual-regression-diff-approver`
|
||||
- name: Reset Commit Status
|
||||
uses: actions/github-script@v7
|
||||
if: ${{ steps.report.outcome == 'success' }}
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const timestamp = Date.now();
|
||||
|
||||
const prNumber = ${{ steps.pr.outputs.id }};
|
||||
const { data } = await github.rest.pulls.get({
|
||||
const prResponse = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber
|
||||
pull_number: ${{ steps.pr.outputs.id }},
|
||||
});
|
||||
const { body: currentBody } = data;
|
||||
const prHeadSha = prResponse.data.head.sha;
|
||||
|
||||
let newBody = currentBody.replace(/<!-- timestamp:[^>]-->/, '').trim();
|
||||
newBody = newBody + `\n\n<!-- timestamp: ${timestamp} -->`;
|
||||
const fullContent = `${{ toJSON(steps.report.outputs.content) }}`;
|
||||
const hasVisualDiffSuccess = fullContent.includes('VISUAL_DIFF_SUCCESS');
|
||||
const hasVisualDiffFailed = fullContent.includes('VISUAL_DIFF_FAILED');
|
||||
|
||||
github.rest.pulls.update({
|
||||
const mergedStatus = hasVisualDiffSuccess ? 'success' : hasVisualDiffFailed ? 'failure' : 'pending';
|
||||
|
||||
await github.rest.repos.createCommitStatus({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber,
|
||||
body: newBody
|
||||
});
|
||||
sha: prHeadSha,
|
||||
state: mergedStatus,
|
||||
context: 'Visual Regression Diff Wait Approve',
|
||||
description: hasVisualDiffSuccess ? 'Visual diff check pass' : 'Visual diff check failed',
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user