Skip to content

gh issue comment requires repository-projects: read permission on Actions #4785

@adityasharad

Description

@adityasharad

Describe the bug

gh issue comment fails with GraphQL error: Resource not accessible by integration when used with a GitHub Actions token that doesn't have repository-projects: read permission.

Occurs with GitHub CLI 2.2.0 (current default on ubuntu-latest on Actions).

Steps to reproduce the behavior

  1. Find an existing issue on a repo.
  2. Create a GitHub Actions workflow on the same repo with the following:
on:
  workflow_dispatch:
jobs:
  create-comment:
    name: Create comment
    permissions:
      contents: read
      issues: write
      # repository-projects: read # fails without this
    steps:
      - name: Create comment
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
        run: |
          set -x
          gh issue comment https://github.com/$GITHUB_REPOSITORY/issues/$number --body "comment body" # replace $number
  1. Run the workflow and see error.
  2. Uncomment the repository-projects: read permission, run the workflow again, and see success.

Expected vs actual behavior

Expected: gh issue comment successfully creates an issue comment even if the token doesn't have permission to access repo projects.

Logs

GraphQL error: Resource not accessible by integration
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedContributions welcomepriority-2Affects more than a few users but doesn't prevent core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions