chore: use single update status of diff action

This commit is contained in:
二货机器人 2024-11-21 10:14:55 +08:00
parent 4dfa7ddf5e
commit 2116659f52

View File

@ -77,6 +77,16 @@ jobs:
const mergedStatus = diffPassed ? 'success' : hasDiffFailed ? 'failure' : 'pending'; const mergedStatus = diffPassed ? 'success' : hasDiffFailed ? 'failure' : 'pending';
console.log('Status:', mergedStatus); console.log('Status:', mergedStatus);
const { data: currentStatuses } = await github.rest.repos.listCommitStatusesForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: prHeadSha,
});
const currentStatus = currentStatuses.find(status => status.context === 'Visual Regression Diff Wait Approve');
if (currentStatus && currentStatus.state === mergedStatus) {
console.log('Status has not changed, no need to update:', currentStatus.state);
} else {
await github.rest.repos.createCommitStatus({ await github.rest.repos.createCommitStatus({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@ -85,6 +95,7 @@ jobs:
context: 'Visual Regression Diff Wait Approve', context: 'Visual Regression Diff Wait Approve',
description: diffPassed ? 'Visual diff is acceptable' : 'Visual diff is not pass', description: diffPassed ? 'Visual diff is acceptable' : 'Visual diff is not pass',
}); });
}
if (hasDiffSuccess || (hasDiffFailed && hasMemberApprove)) { if (hasDiffSuccess || (hasDiffFailed && hasMemberApprove)) {
return 'success'; return 'success';