Skip to content

ci: only post coverage comment for same-repo pull requests - #1195

Closed
Eimen2018 wants to merge 1 commit into
Stacked-Org:masterfrom
Eimen2018:ci/skip-coverage-comment-on-fork-prs
Closed

Eimen2018 wants to merge 1 commit into
Stacked-Org:masterfrom
Eimen2018:ci/skip-coverage-comment-on-fork-prs

Conversation

@Eimen2018

Copy link
Copy Markdown
Collaborator

Summary

Every pull request opened from a fork currently fails CI at the "Report code coverage" step with Resource not accessible by integration, even when dart fix, analysis and flutter test all pass. Recent examples: #1167, #1169, #1192, #1193.

Cause

zgosalvez/github-actions-report-lcov posts a coverage comment on the PR using the github-token input. For pull_request events from forks, GitHub hands the workflow a read-only GITHUB_TOKEN, so the comment API call is rejected and the step fails.

Fix

The action documents github-token as optional and skips commenting when it is empty. This change passes the token only when the PR head is in this repository:

github-token: ${{ github.event.pull_request.head.repo.full_name == github.repository && secrets.GITHUB_TOKEN || '' }}

Same-repo branches keep the coverage comment. Fork PRs still run coverage and upload the HTML artifact, they just do not comment.

Once merged, re-running checks on the open fork PRs will pick this up since the run uses the merge commit with master.

🤖 Generated with Claude Code

The lcov report step posts a PR comment using GITHUB_TOKEN, which is
read-only for pull requests from forks, so every fork PR failed with
'Resource not accessible by integration' even when lint and tests passed.
The action skips commenting when no token is given, so pass the token
only for same-repository branches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Eimen2018

Copy link
Copy Markdown
Collaborator Author

Closing for now. The PRs this was blocking have been reopened from branches in this repository, so they no longer hit the read-only token limitation. The underlying problem still applies to pull requests from forks: the coverage comment step fails with "Resource not accessible by integration" even when lint and tests pass. This change can be reopened if that becomes a nuisance for outside contributors.

@Eimen2018 Eimen2018 closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant