Skip to content

Commit 24dbe96

Browse files
authored
fix script (base#1223)
1 parent ce51c6e commit 24dbe96

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

.github/workflows/file-size-checker.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,20 @@ jobs:
8585
const largeFiles = `${{ steps.check-sizes.outputs.large_files }}`;
8686
8787
try {
88-
console.log('Repository:', context.payload.repository.name);
89-
console.log('Owner:', context.payload.repository.owner.login);
90-
console.log('SHA:', context.payload.pull_request.head.sha);
91-
92-
// Set status check that will be used by branch protection
93-
await github.rest.repos.createCommitStatus({
94-
owner: context.payload.repository.owner.login,
95-
repo: context.payload.repository.name,
96-
sha: context.payload.pull_request.head.sha,
97-
state: hugeFiles ? 'failure' : 'success',
98-
context: 'File Size Check',
99-
description: hugeFiles ? 'Files over 40MB found' : 'All files within size limits',
100-
target_url: `https://github.com/${context.payload.repository.owner.login}/${context.payload.repository.name}/actions/runs/${context.runId}`
101-
});
102-
103-
// Only comment if issues were found
88+
// Only create status check if we have permission (not a fork PR)
89+
if (context.payload.pull_request.head.repo.full_name === context.payload.repository.full_name) {
90+
await github.rest.repos.createCommitStatus({
91+
owner: context.payload.repository.owner.login,
92+
repo: context.payload.repository.name,
93+
sha: context.payload.pull_request.head.sha,
94+
state: hugeFiles ? 'failure' : 'success',
95+
context: 'File Size Check',
96+
description: hugeFiles ? 'Files over 40MB found' : 'All files within size limits',
97+
target_url: `https://github.com/${context.payload.repository.owner.login}/${context.payload.repository.name}/actions/runs/${context.runId}`
98+
});
99+
}
100+
101+
// Comments should work for both fork and non-fork PRs
104102
if (hugeFiles || largeFiles) {
105103
let comment = '## ⚠️ File Size Check Results\n\n';
106104
@@ -124,5 +122,10 @@ jobs:
124122
} catch (error) {
125123
console.error('Error:', error);
126124
console.error('Context:', JSON.stringify(context.payload, null, 2));
127-
core.setFailed(error.message);
125+
// Only ignore status check permission errors for fork PRs
126+
if (error.status === 403 && context.payload.pull_request.head.repo.full_name !== context.payload.repository.full_name) {
127+
console.log('Ignoring status check permission error for fork PR');
128+
} else {
129+
core.setFailed(error.message);
130+
}
128131
}

0 commit comments

Comments
 (0)