Skip to content

Commit aa96eed

Browse files
akurtakovCopilot
andcommitted
Make license review PR comment best-effort
Pull requests opened from forks run with a read-only GITHUB_TOKEN, so creating a comment fails with 'Resource not accessible by integration'. Wrap the comment creation in a try/catch so this no longer raises an unhandled error: the dependency list is still written to the job summary and the run is still marked as failed. Same-repo PRs and the /request-license-review issue_comment flow can still post the comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b818803 commit aa96eed

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/licensecheck.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,20 @@ jobs:
190190
core.summary.addRaw(body).write();
191191
const prNumber = context.issue && context.issue.number;
192192
if (prNumber) {
193-
await github.rest.issues.createComment({
194-
owner: context.repo.owner,
195-
repo: context.repo.repo,
196-
issue_number: prNumber,
197-
body,
198-
});
193+
// Posting a comment requires a token with write access. For pull
194+
// requests opened from forks the GITHUB_TOKEN is read-only, so the
195+
// comment can't be posted there; the '/request-license-review'
196+
// issue_comment flow runs in the base repo and can comment instead.
197+
try {
198+
await github.rest.issues.createComment({
199+
owner: context.repo.owner,
200+
repo: context.repo.repo,
201+
issue_number: prNumber,
202+
body,
203+
});
204+
} catch (err) {
205+
core.warning(`Could not post review comment (likely a fork pull request with a read-only token): ${err}`);
206+
}
199207
} else {
200208
core.info('No pull request context available; skipping PR comment.');
201209
}

0 commit comments

Comments
 (0)