|
107 | 107 | - '*' |
108 | 108 |
|
109 | 109 | permissions: |
110 | | - contents: write |
111 | | - checks: write |
| 110 | + contents: read |
112 | 111 | pull-requests: write |
113 | 112 |
|
114 | 113 | jobs: |
@@ -540,16 +539,40 @@ If you want auto-update the coverage badge on your README, you can see the [work |
540 | 539 |
|
541 | 540 | **Issue**: The action runs successfully but no comment appears on the PR. |
542 | 541 |
|
| 542 | +**Root Cause**: This is usually caused by insufficient GitHub token permissions. The `GITHUB_TOKEN` needs write access to create/update PR comments. |
| 543 | + |
| 544 | +**Common Error Messages**: |
| 545 | +- `Error: Resource not accessible by integration` |
| 546 | +- `HttpError: Resource not accessible by integration` |
| 547 | +- `403 Forbidden` errors in the action logs |
| 548 | + |
543 | 549 | **Solutions**: |
544 | 550 |
|
545 | | -- Ensure proper permissions are set: |
546 | | - ```yaml |
547 | | - permissions: |
548 | | - contents: write |
549 | | - pull-requests: write |
550 | | - ``` |
551 | | -- For `workflow_dispatch`, provide the `issue-number` input |
552 | | -- Check if `hide-comment` is set to `false` |
| 551 | +1. **Add permissions block to your workflow** (Recommended): |
| 552 | + ```yaml |
| 553 | + permissions: |
| 554 | + contents: read # Required for checkout and comparing commits |
| 555 | + pull-requests: write # Required for creating/updating PR comments |
| 556 | + ``` |
| 557 | + |
| 558 | +2. **For `push` events with commit comments**, use: |
| 559 | + ```yaml |
| 560 | + permissions: |
| 561 | + contents: write # Required for creating commit comments |
| 562 | + pull-requests: write # If you also want PR comments |
| 563 | + ``` |
| 564 | + |
| 565 | +3. **Repository/Organization Settings** (Admin access required): |
| 566 | + - Go to Settings > Actions > General |
| 567 | + - Under "Workflow permissions", select "Read and write permissions" |
| 568 | + - Note: This affects all workflows, so adding permissions to individual workflows is more secure |
| 569 | + |
| 570 | +4. **Other checks**: |
| 571 | + - For `workflow_dispatch` events, provide the `issue-number` input |
| 572 | + - Verify `hide-comment` is not set to `true` |
| 573 | + - Check branch protection rules aren't blocking automated comments |
| 574 | + |
| 575 | +**Why it works on forks but not main repos**: Forks often have different default permission settings than the main repository. Organizations frequently set restrictive defaults for security. |
553 | 576 |
|
554 | 577 | ### Unrecognized Arguments Error |
555 | 578 |
|
|
0 commit comments