Security Audit fails on every fork PR: the comment step cannot post with a read-only token
component-security-validation.yml fails on every pull request that comes from a fork, at the "Comment PR with Results" step:
HttpError: Resource not accessible by integration
POST /repos/davila7/claude-code-templates/issues/<n>/comments 403A pull_request event from a fork gets a read-only GITHUB_TOKEN, so the job's permissions: pull-requests: write is not granted and actions/github-script cannot post.
The audit itself is fine. "Run Security Audit" carries continue-on-error: true and succeeds, so the job's only failure mode is the comment. The result is that a fork contributor gets a red X on a check that found nothing wrong with their change, on a workflow that triggers on any cli-tool/components/**/*.md edit.
Recent runs, for confirmation:
| event | branch | result |
|---|---|---|
| pull_request | fork branch | failure at the comment step |
| pull_request | same-repo branch | success |
| push | main | success, the comment step is skipped |
The smallest fix is to skip the comment when the head repo is not this one:
- name: Comment PR with Results
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always()That keeps the comment for internal PRs, and fork PRs still get the JSON report and the uploaded artifact, which both work today. The alternative is moving the job to pull_request_target, which does grant a writable token but runs the base branch's workflow against fork code, so the if guard looks like the safer trade to me.
I have not sent a PR for this because it touches .github/, and the contributor guidance says a fork PR should only carry files under cli-tool/components/. Happy to send one if you would rather have it as a patch.
Source: davila7/claude-code-templates