Skip to content

Add permissions block to pr-checks workflow#43

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-workflow-permissions
Closed

Add permissions block to pr-checks workflow#43
Copilot wants to merge 3 commits intomainfrom
copilot/fix-workflow-permissions

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

The PR Checks workflow fails with "Resource not accessible by integration" when actions/github-script@v7 calls github.rest.issues.createComment() — the default GITHUB_TOKEN lacks write access to PRs.

  • Added top-level permissions with pull-requests: write and issues: write to .github/workflows/pr-checks.yml
permissions:
  pull-requests: write
  issues: write
Original prompt

Prompt Yourself: Solution to Failing Job

Root Cause: The step using actions/github-script@v7 fails with RequestError [HttpError]: "Resource not accessible by integration." The failure occurs at:
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: comment
});
This means the workflow does not have sufficient permissions to comment on the pull request.

Solution:

  1. Fix Permissions in Workflow
    Add permissions to the workflow YAML to authorize PR commenting:

permissions:
pull-requests: write
issues: write

Add this under the top-level workflow definition (after name/on):

name: PR Checks
on:
pull_request:
types: [opened, reopened, synchronize, edited]
permissions:
pull-requests: write
issues: write
jobs:
validate:
...

Reference: GitHub Actions documentation — workflow permissions

  1. Confirm the PR Checks Workflow uses actions/github-script@v7 as required. No code changes needed inside the script.

Code Suggestion (diff for .github/workflows/pr-checks.yml):

  • permissions:
  • pull-requests: write
  • issues: write

This will grant the workflow sufficient permissions to create comments on PRs and resolve the job failure.\


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix permissions for commenting on pull requests Add permissions block to pr-checks workflow Feb 9, 2026
Copilot AI requested a review from groupthinking February 9, 2026 22:00
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@groupthinking groupthinking marked this pull request as ready for review February 9, 2026 22:00
Copilot AI review requested due to automatic review settings February 9, 2026 22:00
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🔍 PR Validation

⚠️ PR title should follow conventional commits format

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the PR Checks GitHub Actions workflow to grant the GITHUB_TOKEN the write permissions needed for the workflow’s actions/github-script@v7 step to comment on pull requests.

Changes:

  • Added a top-level permissions block to .github/workflows/pr-checks.yml.
  • Granted pull-requests: write and issues: write at the workflow level.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment on lines +6 to 10
pull-requests: read
issues: write
jobs:
validate:
runs-on: ubuntu-latest
Copy link

Choose a reason for hiding this comment

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

Bug: The pr-checks.yml workflow has insufficient permissions. It uses pull-requests: read but needs pull-requests: write to post comments on pull requests via github.rest.issues.createComment().
Severity: CRITICAL

Suggested Fix

In the pr-checks.yml workflow file, change the permissions block for the pr-checks job. Update pull-requests: read to pull-requests: write to grant the necessary permissions for creating comments on pull requests.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .github/workflows/pr-checks.yml#L6-L10

Potential issue: The `pr-checks.yml` workflow is configured with `pull-requests: read`
permission. However, the workflow attempts to post a comment on a pull request using
`github.rest.issues.createComment()`. This API call requires `pull-requests: write`
permission to operate on pull requests. With only read access, the call will fail,
raising a "Resource not accessible by integration" error. This prevents the workflow
from successfully posting validation results as a PR comment, causing a runtime failure.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

pull_request:
types: [opened, reopened, synchronize, edited]
permissions:
pull-requests: read
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The PR description states that pull-requests: write is needed to allow github.rest.issues.createComment() to comment on PRs, but the implementation sets pull-requests: read instead. This will not grant sufficient permissions to create comments on pull requests. The workflow will continue to fail with "Resource not accessible by integration" error. Change this to pull-requests: write as described in the PR.

Copilot uses AI. Check for mistakes.
@groupthinking
Copy link
Owner

Superseded — main already has correct permissions block (contents: read, pull-requests: write). This PR would downgrade pull-requests to read, breaking the createComment call.

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.

3 participants