Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ name: Commit Check

on:
pull_request:
branches: 'main'
branches: ['main']
workflow_dispatch:

jobs:
commit-check:
runs-on: ubuntu-latest
permissions: # use permissions because of use pr-comments
contents: read
issues: read
pull-requests: write
Comment on lines 11 to 14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify that issues: read is sufficient for posting PR comments.

The PR adds issues: read permission to enable PR comment posting. However, the linked issue #143 indicates the reporter resolved the 403 error by adding issues: write, which suggests write access may be required to post comments.

Please verify that issues: read alone is sufficient to post PR comments, or confirm whether issues: write should be used instead.


🌐 Web query:

GitHub Actions permissions for posting pull request comments - issues read vs write requirements

💡 Result:

Short answer: to post (create/update/delete) a pull request comment from a GitHub Action you need the Issues write permission (or Pull requests write in some cases). Pull request comments are handled by the Issues API (every PR is also an issue), and the REST endpoints for creating/updating/deleting issue comments require write repository permission for "Issues" (or an equivalent "Pull requests: write" permission listed for some endpoints). Configure your GITHUB_TOKEN with e.g.

permissions:
issues: write

(or pull-requests: write) in the workflow if the token's default permissions do not allow it. See GitHub docs for the issue-comments endpoints and token permission control. [1][2][3]

Sources:
[1] REST API — Issue comments (create/update/delete) (GitHub Docs). (docs.github.com)
[2] REST API — Issues endpoints (permissions required: "Issues" repo permissions write / or "Pull requests" write for some actions). (docs.github.com)
[3] Controlling permissions for GITHUB_TOKEN in Actions (how to set issues: write / pull-requests: write). (docs.github.com)

Citations:


Change issues: read to issues: write to enable PR comment posting.

To post (create/update/delete) a pull request comment from a GitHub Action, you need the Issues write permission. Pull request comments are handled by the Issues API, and the REST endpoints for creating/updating/deleting issue comments require write repository permission for "Issues". The current configuration with issues: read will fail with a 403 error. Update line 13 to issues: write.

🤖 Prompt for AI Agents
.github/workflows/commit-check.yml around lines 11 to 14: the workflow currently
sets "issues: read" which prevents the action from creating/updating/deleting PR
comments; change the permission to "issues: write" on line 13 so the workflow
has write access to the Issues API and can post PR comments, keeping the rest of
the permissions unchanged.

steps:
- uses: actions/checkout@v5
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
runs-on: ubuntu-latest
permissions: # use permissions because use of pr-comments
contents: read
issues: read
pull-requests: write
steps:
- uses: actions/checkout@v5
Expand Down Expand Up @@ -123,7 +124,9 @@ jobs:
- Default: `false`

> [!IMPORTANT]
> `pr-comments` is an experimental feature. By default, it's disabled. To use it, you need to set `GITHUB_TOKEN` in the GitHub Action.
> `pr-comments` is an experimental feature. By default, it's disabled. To use it, you need to:
> - Set `GITHUB_TOKEN` in the GitHub Action
> - Add `issues: read` permission (required because PRs use the Issues API)
>
> This feature currently doesn’t work with forked repositories. For more details, refer to issue [#77](https://github.com/commit-check/commit-check-action/issues/77).

Expand Down
Loading