mirror of
https://github.com/placeholder-soft/web.git
synced 2026-01-12 22:45:00 +08:00
fix script (#1223)
This commit is contained in:
35
.github/workflows/file-size-checker.yml
vendored
35
.github/workflows/file-size-checker.yml
vendored
@@ -85,22 +85,20 @@ jobs:
|
||||
const largeFiles = `${{ steps.check-sizes.outputs.large_files }}`;
|
||||
|
||||
try {
|
||||
console.log('Repository:', context.payload.repository.name);
|
||||
console.log('Owner:', context.payload.repository.owner.login);
|
||||
console.log('SHA:', context.payload.pull_request.head.sha);
|
||||
|
||||
// Set status check that will be used by branch protection
|
||||
await github.rest.repos.createCommitStatus({
|
||||
owner: context.payload.repository.owner.login,
|
||||
repo: context.payload.repository.name,
|
||||
sha: context.payload.pull_request.head.sha,
|
||||
state: hugeFiles ? 'failure' : 'success',
|
||||
context: 'File Size Check',
|
||||
description: hugeFiles ? 'Files over 40MB found' : 'All files within size limits',
|
||||
target_url: `https://github.com/${context.payload.repository.owner.login}/${context.payload.repository.name}/actions/runs/${context.runId}`
|
||||
});
|
||||
// Only create status check if we have permission (not a fork PR)
|
||||
if (context.payload.pull_request.head.repo.full_name === context.payload.repository.full_name) {
|
||||
await github.rest.repos.createCommitStatus({
|
||||
owner: context.payload.repository.owner.login,
|
||||
repo: context.payload.repository.name,
|
||||
sha: context.payload.pull_request.head.sha,
|
||||
state: hugeFiles ? 'failure' : 'success',
|
||||
context: 'File Size Check',
|
||||
description: hugeFiles ? 'Files over 40MB found' : 'All files within size limits',
|
||||
target_url: `https://github.com/${context.payload.repository.owner.login}/${context.payload.repository.name}/actions/runs/${context.runId}`
|
||||
});
|
||||
}
|
||||
|
||||
// Only comment if issues were found
|
||||
// Comments should work for both fork and non-fork PRs
|
||||
if (hugeFiles || largeFiles) {
|
||||
let comment = '## ⚠️ File Size Check Results\n\n';
|
||||
|
||||
@@ -124,5 +122,10 @@ jobs:
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
console.error('Context:', JSON.stringify(context.payload, null, 2));
|
||||
core.setFailed(error.message);
|
||||
// Only ignore status check permission errors for fork PRs
|
||||
if (error.status === 403 && context.payload.pull_request.head.repo.full_name !== context.payload.repository.full_name) {
|
||||
console.log('Ignoring status check permission error for fork PR');
|
||||
} else {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user