Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix: skip coverage PR comments for fork pull requests (#1308)

Aman Agarwal325e56e122f8
diff --git a/.github/workflows/ui-test.yml b/.github/workflows/ui-test.yml
index d0756953..060e94e9 100644
--- a/.github/workflows/ui-test.yml
+++ b/.github/workflows/ui-test.yml
@@ -80,27 +80,43 @@ jobs:
: []),
].join('\n');
- const { data: comments } = await github.rest.issues.listComments({
- owner: context.repo.owner,
- repo: context.repo.repo,
- issue_number: context.issue.number,
- });
-
- const existing = comments.find((c) => c.body.includes(MARKER));
- if (existing) {
- await github.rest.issues.updateComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- comment_id: existing.id,
- body,
- });
+ const fromFork =
+ context.payload.pull_request?.head?.repo?.full_name !==
+ context.repo.owner + '/' + context.repo.repo;
+
+ if (!fromFork) {
+ try {
+ const { data: comments } = await github.rest.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ });
+
+ const existing = comments.find((c) => c.body.includes(MARKER));
+ if (existing) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: existing.id,
+ body,
+ });
+ } else {
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ body,
+ });
+ }
+ } catch (error) {
+ core.warning(
+ `Could not post coverage comment: ${error.message}`
+ );
+ }
} else {
- await github.rest.issues.createComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- issue_number: context.issue.number,
- body,
- });
+ core.info(
+ 'Skipping PR coverage comment: fork PRs cannot write comments with GITHUB_TOKEN.'
+ );
}
if (overall < 80) {